home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / util / rexx / FWCalendar.lha / FWCalendar / FWCalendar.rexx < prev    next >
OS/2 REXX Batch file  |  2000-10-23  |  277KB  |  7,293 lines

  1. /*
  2.   FWCalendar.rexx Macro
  3.   Creates calendars on FinalWriter v 4.x (SoftWood) & PageStream v 3.x
  4.   $VER: FWCalendar.rexx v4.09b (23 Oct 2000)
  5.   ©Ron Goertz (goertz@earthlink.net)
  6. */
  7. options results
  8. options failat 11
  9. signal on syntax
  10. Numeric Digits 14
  11.  
  12. parse source . . . FullCallPath . CallHost
  13. CallHost = strip(CallHost)
  14. ScriptDir = PathPart(FullCallPath)
  15.  
  16. CurrentDir = upper(Pragma('D'))
  17. if right(CurrentDir, 1) ~= ':' then CurrentDir = CurrentDir'/'
  18.  
  19. call AddLibraries
  20. if ErrorCount > 0 then call Cleanup
  21.  
  22. address value DetermineHost()
  23. call GetSetupInfo
  24.  
  25. if CalType < 3 then do
  26.   if CalType == 1 then do
  27.     PrevMonth = Month - 1
  28.       if PrevMonth = 0 then do
  29.       PrevMonth = 12
  30.       PrevYear = Year - 1
  31.     end
  32.     else PrevYear = Year
  33.  
  34.     NextMonth = Month + 1
  35.     if NextMonth = 13 then do
  36.       NextMonth = 1
  37.       NextYear = Year + 1
  38.     end
  39.     else NextYear = Year
  40.  
  41.     Calendar = Month.Month' 'EnteredYear
  42.  
  43.     Mn = right(Month, 2, '0')
  44.     if DataType(Month) == 'NUM' then call setclip('FWC_CalMonth', Month)
  45.     if DataType(EnteredYear) == 'NUM' then call setclip('FWC_CalYear', EnteredYear)
  46.  
  47.     call SetVariables
  48.     call MonthlyCalendar
  49.   end
  50.   else do
  51.     call SetVariables
  52.     StartMonth = Month
  53.     do MonthNumber = StartMonth to EndMonth
  54.       if MonthNumber > 12 then do
  55.         Month = MonthNumber - 12
  56.         Year = EnteredYear + 1
  57.       end
  58.       else do
  59.         Month = MonthNumber
  60.         Year = EnteredYear
  61.       end
  62.  
  63.       PrevMonth = Month - 1
  64.       if PrevMonth = 0 then do
  65.         PrevMonth = 12
  66.         PrevYear = Year - 1
  67.       end
  68.       else PrevYear = Year
  69.  
  70.       NextMonth = Month + 1
  71.       if NextMonth = 13 then do
  72.         NextMonth = 1
  73.         NextYear = Year + 1
  74.       end
  75.       else NextYear = Year
  76.  
  77.       Calendar = Month.Month' 'EnteredYear
  78.       Mn = right(Month, 2, '0')
  79.  
  80.       call MonthlyCalendar
  81.       if MonthNumber ~= EndMonth then do
  82.         if DoHide == 1 then do
  83.           REVEALWINDOW ALL
  84.           DISPLAY PAGE NEXT
  85.           HIDEWINDOW
  86.         end
  87.         else DISPLAY PAGE NEXT
  88.       end
  89.     end
  90.   end
  91. end
  92. else do
  93.   call SetVariables
  94.   Calendar = EnteredYear
  95.   call YearlyCalendar
  96. end
  97.  
  98. call Cleanup
  99. exit
  100.  
  101. /***//*** YearlyCalendar ***/
  102. YearlyCalendar:
  103.   call MiniCalPreCalc(FYMiniCal, MiniCalWidth)
  104.  
  105.   Year = EnteredYear
  106.   interpret 'StartYear = Day.'DateInfo('W', Year'0101', 'S')
  107.  
  108.   YearOffset = 7 - StartYear
  109.   if YearOffset == 7 then YearOffset = 0
  110.  
  111.   if (Year//4 == 0 & Year//100 > 0) | Year//400 == 0 then MonthLength.2 = 29
  112.   else MonthLength.2 = 28
  113.  
  114.   CalTop = Margin.Top
  115.   do r = 0 to 3
  116.     Margin.Top = CalTop + r * (7*Height.FYMiniCal + MiniCalSpacing)
  117.     do c = 0 to 2
  118.       Month = r * 3 + c + 1
  119.       Mn = right(Month, 2, '0')
  120.       TempDate = Year''Mn'01'
  121.       if (Year//4 == 0 & Year//100 > 0) | Year//400 == 0 Then MonthLength.2 = 29
  122.       interpret 'StartDate = Day.'DateInfo('W', TempDate, 'S')
  123.       call DrawMiniCal(0, MiniCalWidth, FYMiniCal)
  124.     end
  125.   end
  126.  
  127.   if DoCopyright == 1 then call RightText(PrintText(0, CalTop + 28 * Height.FYMiniCal + 3 * MiniCalSpacing, 4pt, 'N', Black$, 100, CNotice), Margin.Left + PrintWidth)
  128.  
  129.   return
  130. /**/
  131.  
  132. /***//*** MonthlyCalendar ***/
  133. MonthlyCalendar:
  134.   if (DoSunRise ~= 0) | (DoSunSet ~= 0) then do
  135.     StartDST = DateInfo('I', Year'04'right(CalculateDate(4, 'Monday', 7), 2, '0'), 'S') /* First Sunday in April */
  136.     EndDST   = DateInfo('I', Year'10'CalculateDate(10, 'Friday', 31), 'S') /* Last Sunday in October */
  137.   end
  138.  
  139.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  140.  
  141.   TempDate  = Year''Mn'01'
  142.   IDay      = DateInfo('I', TempDate, 'S') - 1
  143.   interpret 'StartYear = Day.'DateInfo('W', Year'0101', 'S')
  144.  
  145.   YearOffset = 7 - StartYear
  146.   if YearOffset == 7 then YearOffset = 0
  147.  
  148.   if (Year//4 == 0 & Year//100 > 0) | Year//400 == 0 Then do
  149.     LeapYear = 1
  150.     MonthLength.2 = 29
  151.   end
  152.   else do
  153.     LeapYear = 0
  154.     MonthLength.2 = 28
  155.   end
  156.  
  157.   if (PrevYear//4 == 0 & PrevYear//100 > 0) | PrevYear//400 == 0 Then PrevLeapYear = 1
  158.   else PrevLeapYear = 0
  159.  
  160.   interpret 'StartDate = Day.'DateInfo('W', TempDate, 'S')
  161.   if (DoHighlights == 1) | (DoImages == 1) then call SetHighLights
  162.   if DoPhases ~= '' then call GetPhases(Year, Month)
  163.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  164.  
  165.   /* No other objects should be drawn overlapping 0,0 */
  166.   PrefsString = 'FWC'TempDate''PrefsFile
  167.   StringCount = trunc(length(PrefsString) / 25)
  168.   NextString = 0
  169.  
  170.   do i = StringCount to 0 by -1
  171.     PrintString = substr(PrefsString, (i * 25) + 1, 25)
  172.     if NextString ~= 0 then PrintString = PrintString'|'NextString'|'
  173.     NextString = PrintText(0, 0, 4pt, 'N', White$, 100, PrintString)
  174.   end
  175.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  176.  
  177. /***//*** Draw dates and optional highlights ***/
  178.   Day             = - StartDate
  179.   GridLineTop.    = CalTop
  180.   GridLineBottom. = CalTop + BoxHeight*5
  181.   GridLineLeft.   = Margin.Left
  182.   GridLineRight.  = CalRight
  183.   GridLineRight.6 = 0
  184.   SplitDay.       = 0
  185.   MaxRow          = 0
  186.  
  187.   if (DoTopExtraWk ~= 1) & (trunc((StartDate + MonthLength.Month)/7) == 5) then do
  188.     do i = 1 to (StartDate + MonthLength.Month)//7
  189.       SplitDay = MonthLength.Month + 1 - i
  190.       SplitDay.SplitDay = 1
  191.       SplitDay = MonthLength.Month + 1 - i - 7
  192.       SplitDay.SplitDay = 1
  193.     end
  194.   end
  195.  
  196.   Width.WidthOfDate1 = GetFontWidth(Date, 'N', '1')
  197.   Width.WidthOfDate8 = GetFontWidth(Date, 'N', '8')
  198.  
  199.   if (DoRandom ~= '') & (exists(ScriptDir'FWCRandom.txt')) then do
  200.     UsedRandoms = ''
  201.     RandomFile = ReadFile(ScriptDir'FWCRandom.txt')
  202.     call openv('RandomFile')
  203.     RandomCount = length(RandomFile) - length(compress(RandomFile, '|'))
  204.   end
  205.   else DoRandom = 0
  206.  
  207.   if (DoHistory ~= '') & (exists(ScriptDir'FWCHistory/'right(Month, 2, '0'))) then do
  208.     UsedRandoms = ''
  209.     RandomFile = ReadFile(ScriptDir'FWCHistory/'right(Month, 2, '0'))
  210.   end
  211.   else DoHistory = 0
  212.  
  213.   Do CRow = 0 to 5
  214.     CurrentRow = CRow
  215.     if (CRow = 5) & (DoTopExtraWk == 1) then CurrentRow = 0
  216.     BoxTop  = CalTop + BoxHeight*CurrentRow
  217.     if (CRow = 5) & (DoTopExtraWk ~= 1) then BoxTop = CalTop + BoxHeight*4.5
  218.     if CRow ~= 5 then MaxRow = MaxRow + 1
  219.  
  220.     Do CurrentColumn = 0 to 6
  221.       Day = Day + 1
  222.       BackgroundColor = Background.Standard
  223.       if SplitDay.Day == 1 then BHeight = BoxHeight/2
  224.       else BHeight = BoxHeight
  225.       JulianDay = IDay + Day
  226.       BoxLeft = Margin.Left + BoxWidth * CurrentColumn
  227.       PrintDay = ''
  228.  
  229.       /* Days for previous & next months */
  230.       If ((Day < 1) | (Day > MonthLength.Month)) then do
  231.  
  232.         /* Previous month */
  233.         if Day < 1 then do
  234.           if DoExtended then PrintDay = MonthLength.PrevMonth + Day
  235.           GridLineTop.CurrentColumn = CalTop + BoxHeight
  236.           GridLineLeft.0 = Margin.Left + BoxWidth * (CurrentColumn + 1)
  237.         end
  238.  
  239.         /* Next month */
  240.         else do
  241.           if DoExtended then PrintDay = Day - MonthLength.Month
  242.           interpret 'GridLineBottom.'CurrentColumn+1' = 'CalTop + BoxHeight*4
  243.           CalRow = CurrentRow + 1
  244.           if GridLineRight.CalRow == CalRight then GridLineRight.CalRow = Margin.Left + BoxWidth * CurrentColumn
  245.         end
  246.  
  247.         if DoExtended then do
  248.           if (CurrentColumn = Day.Sunday | CurrentColumn = Day.Saturday) & (Background.Weekend ~= '<'Clear$'>') then BackgroundColor = Background.Weekend
  249.           DayType = 'Extended'
  250.           GridColor = Line.Extended
  251.           if BackgroundColor ~= '<'Clear$'>' then TextColor = AltColor.Extended
  252.           else TextColor = Color.Extended
  253.         end
  254.         else BackgroundColor = '<'Clear$'>'
  255.       end
  256.  
  257.       /* Days for current month */
  258.       else do
  259.         if CRow ~= CurrentRow then do
  260.           GridLineTop.CurrentColumn = CalTop
  261.           interpret 'GridLineTop.'CurrentColumn+1' = 'CalTop
  262.           GridLineRight.6 = Margin.Left + BoxWidth * (CurrentColumn + 1)
  263.         end
  264.  
  265.         if (CurrentColumn = Day.Sunday | CurrentColumn = Day.Saturday) & (Background.Weekend ~= '<'Clear$'>') then BackgroundColor = Background.Weekend
  266.  
  267.         /* Print Highlight */
  268.         if Highlight.Month.Day ~= '' & DoHighlights == 1 then do
  269.           if TopOption ~= 0 then Highlight.Month.Day = '//'Highlight.Month.Day
  270.           DailyHLCount = 0
  271.           SearchPos    = 1
  272.           Found        = 1
  273.           do until Found == 0
  274.             Found = pos('//', Highlight.Month.Day, SearchPos)
  275.             if Found > 0 then do
  276.               HighlightText = substr(Highlight.Month.Day, SearchPos, Found - SearchPos)
  277.               SearchPos = Found + 2
  278.             end
  279.             else HighlightText = substr(Highlight.Month.Day, SearchPos)
  280.  
  281.             ColorMarker = pos('00'x, HighlightText)
  282.             if ColorMarker > 0 then do
  283.               TextColor = left(HighlightText, ColorMarker - 1)
  284.               HighlightText = substr(Highlighttext, ColorMarker + 1)
  285.             end
  286.             else TextColor = ''
  287.  
  288.             /* Draw background colors for highlight days */
  289.             if (right(HighlightText, 1) == '#') & (Background.HighlightH ~= '<'Clear$'>') then do
  290.               BackgroundColor = Background.HighlightH
  291.               if (TextColor == '') | (TextColor == '<'Clear$'>') then do
  292.                 if (BackgroundColor ~= White$) then TextColor = AltColor.HighlightH
  293.                 else TextColor = Color.HighlightH
  294.               end
  295.             end
  296.             else if Background.Highlight ~= '<'Clear$'>' then do
  297.               BackgroundColor = Background.Highlight
  298.               if (TextColor == '') | (TextColor == '<'Clear$'>') then do
  299.                 if (BackgroundColor ~= White$) then TextColor = AltColor.Highlight
  300.                 else TextColor = Color.Highlight
  301.               end
  302.             end
  303.  
  304.             if (TextColor == '') | (TextColor == '<'Clear$'>') then do
  305.               if right(HighlightText, 1) == '#' then TextColor = Color.HighlightH
  306.               else TextColor = Color.Highlight
  307.             end
  308.  
  309.             if DoDateBox == 1 then HighlightOffset = CurveOffset + 1.25 * DateOffset + 2 * Width.WidthOfDate8
  310.             else do
  311.               Select
  312.                 when Day < 10 then HighlightOffset = Width.WidthOfDate1 / 2 + Width.WidthOfDate8
  313.                 when Day < 20 then HighlightOffset = 1.5 * Width.WidthOfDate1 + Width.WidthOfDate8
  314.                 otherwise HighlightOffset = Width.WidthOfDate1 / 2 + 2 * Width.WidthOfDate8
  315.               end
  316.             end
  317.  
  318.             call PrintHighlight(compress(HighlightText, '#'), 'Highlight')
  319.  
  320.             DailyHLCount = DailyHLCount + 1
  321.           end
  322.         end
  323.         else do
  324.           if DoDailyColors == 1 then do
  325.             Select
  326.               when CurrentColumn == Day.Sunday then TextColor = Color.Sunday
  327.               when CurrentColumn == Day.Monday then TextColor = Color.Monday
  328.               when CurrentColumn == Day.Tuesday then TextColor = Color.Tuesday
  329.               when CurrentColumn == Day.Wednesday then TextColor = Color.Wednesday
  330.               when CurrentColumn == Day.Thursday then TextColor = Color.Thursday
  331.               when CurrentColumn == Day.Friday then TextColor = Color.Friday
  332.               when CurrentColumn == Day.Saturday then TextColor = Color.Saturday
  333.             end
  334.           end
  335.           else if BackgroundColor ~= '<'Clear$'>' then TextColor = AltColor.Date
  336.           else TextColor = Color.Date
  337.         end
  338.  
  339.         if DoMatchColors ~= 1 then do
  340.           if DoDailyColors == 1 then do
  341.             Select
  342.               when CurrentColumn == Day.Sunday then TextColor = Color.Sunday
  343.               when CurrentColumn == Day.Monday then TextColor = Color.Monday
  344.               when CurrentColumn == Day.Tuesday then TextColor = Color.Tuesday
  345.               when CurrentColumn == Day.Wednesday then TextColor = Color.Wednesday
  346.               when CurrentColumn == Day.Thursday then TextColor = Color.Thursday
  347.               when CurrentColumn == Day.Friday then TextColor = Color.Friday
  348.               when CurrentColumn == Day.Saturday then TextColor = Color.Saturday
  349.             end
  350.           end
  351.           else if BackgroundColor ~= '<'Clear$'>' then TextColor = AltColor.Date
  352.           else TextColor = Color.Date
  353.         end
  354.  
  355.         /* Print Day */
  356.         DayType   = 'Normal'
  357.         PrintDay  = Day
  358.         GridColor = Line.Grid
  359.       end
  360.  
  361.       if PrintDay ~= '' then do
  362.         if DoDateBox == 1 then do
  363.           if PrintDay < 10 then LeftEdge = BoxLeft + CurveOffset + Width.WidthOfDate8
  364.           else LeftEdge = BoxLeft + CurveOffset
  365.         end
  366.         else LeftEdge = BoxLeft + CurveOffset
  367.         DayID = PrintText(LeftEdge, BoxTop, Date, 'N', TextColor, Width.Date, PrintDay)
  368.         if DoDateBox == 1 then call BoxDate(TextColor)
  369.         if CRadius ~= 0 then
  370.           call DrawBox(BoxLeft, BoxTop, BoxWidth, BHeight, 'HL', GridColor, 0, , (DayType == 'Extended'), CRadius)
  371.         call DoOptions
  372.       end
  373.  
  374.       if BackgroundColor ~= '<'Clear$'>' then
  375.         call DrawBox(BoxLeft, BoxTop, BoxWidth, BHeight, 0, , 1, BackgroundColor, 1, CRadius)
  376.       if UpdateBusy(Req, 1) == -1 then call Cleanup
  377.  
  378.       if (CRow == 5) & (Day == MonthLength.Month) then leave CRow
  379.     end
  380.     if Day >= MonthLength.Month then leave
  381.   end
  382.   call closev('RandomFile')
  383. /**/
  384.  
  385. /***//*** Draw grids ***/
  386.   LowRow = CRow
  387.   if LowRow = 3 then GridLineBottom. = CalTop + BoxHeight*4
  388.  
  389.   /* Draw note box */
  390.   drop TopNoteLeft
  391.   drop TopNoteRight
  392.   drop BottomNoteLeft
  393.   drop BottomNoteRight
  394.   if DoNoteBox then do
  395.     PrevTop = CalTop
  396.     PrevBottom = GridLineBottom.
  397.     do i = 0 to 7
  398.       if GridLineTop.i > PrevTop then TopNoteLeft = max(i - 1, 0)
  399.       if GridLineTop.i < PrevTop then TopNoteRight = i
  400.       PrevTop = GridLineTop.i
  401.     end
  402.     do i = 0 to 7
  403.       if GridLineBottom.i < PrevBottom then BottomNoteLeft = max(i - 1, 0)
  404.       if GridLineBottom.i > PrevBottom then BottomNoteRight = i
  405.       PrevBottom = GridLineBottom.i
  406.     end
  407.  
  408.     if (symbol('TopNoteLeft') == 'LIT') & (symbol('TopNoteRight') == 'LIT') then do
  409.       TopNoteleft = 0
  410.       TopNoteRight = 0
  411.     end
  412.  
  413.     if (symbol('BottomNoteLeft') == 'LIT') & (symbol('BottomNoteRight') == 'LIT') then do
  414.       BottomNoteleft = 0
  415.       BottomNoteRight = 0
  416.     end
  417.     if (symbol('BottomNoteLeft') == 'VAR') & (symbol('BottomNoteRight') == 'LIT') then BottomNoteRight = 7
  418.  
  419.     if TopNoteRight ~= TopNoteLeft then do
  420.       LeftEdge = Margin.Left + BoxWidth*TopNoteLeft
  421.       RightEdge = Margin.Left + BoxWidth*TopNoteRight
  422.       if CornerRadius == 0 then do
  423.         call DrawLine(LeftEdge, CalTop, RightEdge, CalTop, 'HL', Line.NoteBox)
  424.         if TopNoteLeft == 0 then call DrawLine(Margin.Left, CalTop, Margin.Left, GridLineTop.0, 'HL', Line.NoteBox)
  425.       end
  426.       else call DrawBox(LeftEdge, CalTop, RightEdge - LeftEdge, BoxHeight, 'HL', Line.NoteBox, 0, , 1, CRadius)
  427.       if Background.NoteBox ~= '<'Clear$'>' then
  428.         call DrawBox(LeftEdge, CalTop, RightEdge - LeftEdge, BoxHeight, 0, , 1, Background.NoteBox, 1, CRadius)
  429.       call PrintText(LeftEdge + CurveOffset, CalTop, Date, 'N', Color.NoteBox, Width.Date, Note$':')
  430.     end
  431.  
  432.     if BottomNoteRight ~= BottomNoteLeft then do
  433.       LeftEdge = Margin.Left + BoxWidth*BottomNoteLeft
  434.       RightEdge = Margin.Left + BoxWidth*BottomNoteRight
  435.       if CornerRadius == 0 then do
  436.         call DrawLine(LeftEdge, GridLineBottom.BottomNoteLeft, RightEdge, GridLineBottom.BottomNoteLeft, 'HL', Line.NoteBox)
  437.         call DrawLine(RightEdge, GridLineBottom.BottomNoteLeft, RightEdge, GridLineBottom.BottomNoteRight, 'HL', Line.NoteBox)
  438.       end
  439.       else call DrawBox(LeftEdge, GridLineBottom.BottomNoteRight, RightEdge - LeftEdge, BoxHeight, 'HL', Line.NoteBox, 0, , 1, CRadius)
  440.       if Background.NoteBox ~= '<'Clear$'>' then
  441.         call DrawBox(LeftEdge, GridLineBottom.BottomNoteRight, RightEdge - LeftEdge, BoxHeight, 0, , 1, Background.NoteBox, 1, CRadius)
  442.       call PrintText(LeftEdge + CurveOffset, GridLineBottom.BottomNoteRight, Date, 'N', Color.NoteBox, Width.Date, Note$':')
  443.     end
  444.   end
  445.  
  446.   if CornerRadius == 0 then do
  447.     /* Draw vertical grid */
  448.     do i = 0 to 7
  449.       LeftEdge = Margin.Left + BoxWidth*i
  450.       if DoExtended then do
  451.         if GridLineTop.i > CalTop then
  452.           call DrawLine(LeftEdge, CalTop, LeftEdge, GridLineTop.i, 'HL', Line.Extended)
  453.         if GridLineBottom.i < GridLineBottom.8 then
  454.           call DrawLine(LeftEdge, GridLineBottom.i, LeftEdge, GridLineBottom.8, 'HL', Line.Extended)
  455.       end
  456.       call DrawLine(LeftEdge, GridLineTop.i, LeftEdge, GridLineBottom.i, 'HL', Line.Grid)
  457.     end
  458.  
  459.     /* Draw horizontal grid */
  460.     do i = 0 to min(LowRow + 1, 5)
  461.       TopEdge = CalTop + BoxHeight * i
  462.       if DoExtended then do
  463.         if GridLineLeft.i > Margin.Left then
  464.           call DrawLine(Margin.Left, TopEdge, GridLineLeft.i, TopEdge, 'HL', Line.Extended)
  465.         if GridLineRight.i < CalRight then
  466.           call DrawLine(GridLineRight.i, TopEdge, CalRight, TopEdge, 'HL', Line.Extended)
  467.       end
  468.       call DrawLine(GridLineLeft.i, TopEdge, GridLineRight.i, TopEdge, 'HL', Line.Grid)
  469.     end
  470.  
  471.     if (trunc((StartDate + MonthLength.Month)/7) == 5) & (DoTopExtraWk == 0) then
  472.       call DrawLine(Margin.Left, CalTop + BoxHeight * 4.5, Margin.Left + BoxWidth * ((StartDate + MonthLength.Month)//7), CalTop + BoxHeight * 4.5, 'HL', Line.Grid)
  473.  
  474.     if GridLineRight.6 ~= 0 then call DrawLine(Margin.Left, CalTop, GridLineRight.6, CalTop, 'HL', Line.Grid)
  475.   end
  476.  
  477.   if CalendarBorder ~= 0 then
  478.     call DrawBox(Margin.Left - CalendarBorder, CalTop - CalendarBorder, PrintWidth + 2 * CalendarBorder, MaxRow * BoxHeight + 2 * CalendarBorder, 'HL', Line.CalBorder, 0, , 1, CRadius)
  479.  
  480.   if CalendarShadow ~= 0 then do
  481.     if ShadowType == 'P' then do
  482.       call DrawBox(Margin.Left + PrintWidth + CalendarBorder, CalTop - CalendarBorder + CalendarShadow, CalendarShadow, MaxRow * BoxHeight + 2 * CalendarBorder, 0, , 1, Background.CalShadow, 1, 0)
  483.       call DrawBox(Margin.Left - CalendarBorder + CalendarShadow, CalTop + MaxRow * BoxHeight + CalendarBorder, PrintWidth + 2 * CalendarBorder, CalendarShadow, 0, , 1, Background.CalShadow, 1, 0)
  484.     end
  485.     else call DrawBox(Margin.Left - CalendarBorder + CalendarShadow, CalTop - CalendarBorder + CalendarShadow, PrintWidth + 2 * CalendarBorder, MaxRow * BoxHeight + 2 * CalendarBorder, 0, , 1, Background.CalShadow, 1, CRadius)
  486.   end
  487. /**/
  488.  
  489. /***//*** Draw headers & minicals ***/
  490.   /* Create month/year header */
  491.   if Header$ ~= '' then do
  492.     Text.Top = Margin.Top + TextArea * HeaderLoc
  493.     call CenterText(PrintText(Margin.Left, Text.Top , Header, 'N', Color.Header, Width.Header, BuildString(Header$, HeaderVars)), Margin.Left + PrintWidth/2, .9 * (PrintWidth - DoMiniCals * (2 * MiniCalWidth)), 0)
  494.     if UpdateBusy(Req, 1) == -1 then call Cleanup
  495.   end
  496.  
  497.   if SubHeader$ ~= '' then do
  498.     Text.Top = Margin.Top + TextArea * SubHeaderLoc
  499.     call CenterText(PrintText(Margin.Left, Text.Top , SubHeader, 'N', Color.SubHeader, Width.SubHeader, BuildString(SubHeader$, SubHeaderVars)), Margin.Left + PrintWidth/2, .9 * (PrintWidth - DoMiniCals * (2 * MiniCalWidth)), 0)
  500.     if UpdateBusy(Req, 1) == -1 then call Cleanup
  501.   end
  502.  
  503.   /* Create weekday titles */
  504.   Text.Top = CalTop - (Height.Weekday * 1.15) - CalendarBorder
  505.   Do i = 0 to 6
  506.     WeekdayID.i = PrintText(1, Text.Top, Weekday, 'N', Color.Weekday, Width.Weekday, Day.i)
  507.     if UpdateBusy(Req, 1) == -1 then call Cleanup
  508.   End
  509.  
  510.   /* Position weekday titles */
  511.   MaxWidth = GetMaxWidth('WeekdayID', 6)
  512.   if MaxWidth == 0 then MaxWidth = BoxWidth
  513.  
  514.   Do i = 0 to 6
  515.     call CenterText(WeekdayID.i, Margin.Left + (i + .5) * BoxWidth, 0, .9 * min(1, BoxWidth/MaxWidth))
  516.     if UpdateBusy(Req, 1) == -1 then call Cleanup
  517.   end
  518.  
  519.   if DoMiniCals = 1 then do
  520.     call MiniCalPreCalc(MiniCal, MiniCalWidth)
  521.     call DrawMiniCal(-1, MiniCalWidth, MiniCal)
  522.     call DrawMiniCal(+1, MiniCalWidth, MiniCal)
  523.   end
  524.   /**/
  525.  
  526.   if DoCopyright == 1 then call RightText(PrintText(0, Margin.Top + PrintHeight + 2 * CalendarBorder + CalendarShadow, 4pt, 'N', Black$, 100, CNotice), Margin.Left + PrintWidth)
  527.   if App == 'PGS' then SELECTOBJECT NONE
  528.  
  529.   return
  530. /**/
  531.  
  532. /*** Subroutines ***/
  533. /***//*** AddBGUI (AB) ***/
  534. AddBGUI:
  535.   i = 0; AL_RexxBGUILib = i; AL_Lib.i = 'rexxbgui.library';    AL_MinVersion.i = 4;     AL_Offset.i = -30;  AL_Variable.i = 'RexxBGUILib'; AL_Status.i = "E"
  536.   i = 1; AL_BGUILib = i;     AL_Lib.i = 'bgui.library';        AL_MinVersion.i = 41.1;  AL_Offset.i = '' ;  AL_Variable.i = 'BGUILib';     AL_Status.i = "E"
  537.  
  538.   do i = 0 to 1
  539.     if exists('LIBS:'AL_lib.i) then do
  540.       AL_InstalledVersion = PgmVer('LIBS:'AL_lib.i)
  541.       AL_LibCount = AL_LibCount + 1
  542.       Library.Name.AL_LibCount = AL_Lib.i
  543.       Library.Version.AL_LibCount = AL_InstalledVersion
  544.       if (AL_InstalledVersion < AL_MinVersion.i) | (AL_InstalledVersion == '') then do
  545.         call AddMsg(AL_Status.i, AL_Lib.i' version 'AL_MinVersion.i' is required; your version is 'AL_InstalledVersion'.')
  546.         interpret Al_Variable.i' = 0'
  547.       end
  548.       else do
  549.         if i ~= AL_BGUILib then call addlib(AL_lib.i, 0, AL_Offset.i, trunc(AL_MinVersion.i))
  550.         interpret Al_Variable.i' = 1'
  551.       end
  552.     end
  553.     else do
  554.       interpret Al_Variable.i' = 0'
  555.       if (i = AL_RexxBGUILib) | (i = AL_BGUILib) then do
  556.         if GUIWarning == 0 then do
  557.           GUIWarning = 1
  558.           call AddMsg('E', 'Either the ClassAct files or the BGUI files (see the docs)')
  559.           call AddMsg('E', '  must be installed. Neither could be found...')
  560.         end
  561.       end
  562.       else if AL_Status.i == 'E' then call AddMsg('E', AL_lib.i' is required but could not be found.')
  563.     end
  564.   end
  565.   if RexxBGUILib == 1 then ClassAct = 0
  566.   if (ClassAct == 0) & (bguiopen = 0) then bguiopen = bguiopen()
  567.  
  568.   return
  569. /**/
  570.  
  571. /***//*** AddLibraries (AL) ***/
  572. AddLibraries:
  573.   AL_LibCount      = 0
  574.   DoingCleanup     = 0
  575.   PortList         = show('P')
  576.   InformationCount = 0
  577.   WarningCount     = 0
  578.   ErrorCount       = 0
  579.   HostScreen       = ''
  580.   Req              = 0
  581.   bguiopen         = 0
  582.   Storage          = 'RAM:FWC/'
  583.   ClassAct         = 0
  584.   ForceBGUI        = 0
  585.   ReqAPVersion     = 2.48
  586.   ReqCAVersion     = 42.80
  587.   ClassActMessage  = ''
  588.   AWNPipeMessage   = ''
  589.   GUIWarning       = 0
  590.  
  591.   call TranslationStrings
  592.   interpret ReadFile(ScriptDir'FWCTranslations.txt')
  593.  
  594.   i = 0; AL_DateLib = i;     AL_Lib.i = 'date.library';        AL_MinVersion.i = 33.31; AL_Offset.i = -492; AL_Variable.i = 'DateLib';     AL_Status.i = "W"
  595.   i = 1; AL_RexxMathLib = i; AL_Lib.i = 'rexxmathlib.library'; AL_MinVersion.i = 38.1;  AL_Offset.i = -30;  AL_Variable.i = 'RexxMathLib'; AL_Status.i = "W"
  596.  
  597.   if exists('L:awnpipe-handler') == 1 then do
  598.     AWNPipeVersion  = PgmVer('L:awnpipe-handler')
  599.     if exists('LIBS:gadgets/layout.gadget') == 1 then do
  600.       ClassActVersion = PgmVer('LIBS:gadgets/layout.gadget')
  601.       if ClassActVersion < ReqCAVersion then do
  602.         ClassActMessage = 'ClassAct version 'ReqCAVersion'+ is required; your version is 'ClassActVersion'. BGUI is being used'
  603.         ForceBGUI = 1
  604.       end
  605.       if AWNPipeVersion < ReqAPVersion then do
  606.         AWNPipeMessage = 'AWNPipe version 'ReqAPVersion'+ is required; your version is 'AWNPipeVersion'. BGUI is being used'
  607.         ForceBGUI = 1
  608.       end
  609.       if ForceBGUI == 0 then ClassAct = 1
  610.     end
  611.     else ForceBGUI = 1
  612.   end
  613.   else ForceBGUI = 1
  614.  
  615.   do i = 0 to 1
  616.     if exists('LIBS:'AL_lib.i) then do
  617.       AL_InstalledVersion = PgmVer('LIBS:'AL_lib.i)
  618.       AL_LibCount = AL_LibCount + 1
  619.       Library.Name.AL_LibCount = AL_Lib.i
  620.       Library.Version.AL_LibCount = AL_InstalledVersion
  621. if (i == AL_RexxMathLib) & (AL_InstalledVersion == '38.02') then AL_InstalledVersion = 38.2
  622.       if (AL_InstalledVersion < AL_MinVersion.i) | (AL_InstalledVersion == '') then do
  623.         call AddMsg(AL_Status.i, AL_Lib.i' version 'AL_MinVersion.i' is required; your version is 'AL_InstalledVersion'.')
  624.         interpret Al_Variable.i' = 0'
  625.       end
  626.       else do
  627.         call addlib(AL_lib.i, 0, AL_Offset.i, trunc(AL_MinVersion.i))
  628.         interpret AL_Variable.i' = 1'
  629.       end
  630.     end
  631.     else do
  632.       interpret Al_Variable.i' = 0'
  633.       if AL_Status.i == 'E' then call AddMsg('E', AL_lib.i' is required but could not be found.')
  634.     end
  635.   end
  636.   if (DateLib == 1) | (RexxMathLib == 1) then PhaseLib = 1
  637.   else PhaseLib = 0
  638.  
  639.   if ForceBGUI == 1 then do
  640.     ClassAct = 0
  641.     call AddBGUI
  642.   end
  643.  
  644.   if ErrorCount > 0 then call Cleanup
  645.   return
  646. /**/
  647.  
  648. /***//*** AddMsg (AM) ***/
  649. AddMsg:
  650.   parse arg AM_MsgType, AM_Msg
  651.  
  652.   if AM_MsgType == 'E' then do
  653.     if symbol('ErrorCount') == 'LIT' then ErrorCount = 0
  654.     ErrorCount = ErrorCount + 1
  655.     Error.ErrorCount = AM_Msg
  656.   end
  657.   else if AM_MsgType == 'W' then do
  658.     if symbol('WarningCount') == 'LIT' then WarningCount = 0
  659.     WarningCount = WarningCount + 1
  660.     Warning.WarningCount = AM_Msg
  661.   end
  662.   else do
  663.     if symbol('InformationCount') == 'LIT' then InformationCount = 0
  664.     InformationCount = InformationCount + 1
  665.     Information.InformationCount = AM_Msg
  666.   end
  667.  
  668.   return 0
  669. /**/
  670.  
  671. /***//*** AssignHighlight (AH) ***/
  672. AssignHighlight:
  673.   parse arg AH_Month, AH_Day, AH_Event, AH_Color
  674.  
  675.   if upper(left(AH_Month, 9)) == 'HIGHLIGHT' then parse var AH_Month .'.'AH_Month'.'AH_Day'='AH_Event','AH_Color
  676.   if strip(AH_Event, 'B', '"'||"'") == '' then return 0
  677.   if AH_Month = 13 then AH_Month = Mn - 0
  678.   if AH_Color == '' then AH_Color = '<'Clear$'>'
  679.   AH_Event = strip(AH_Color, 'B', '" '||"'")||'00'x||substr(strip(AH_Event), 2, Length(strip(AH_Event)) - 2)
  680.   AH_DateString = DetermineDate(strip(AH_Month), strip(AH_Day), Year)
  681.   AH_Month = word(AH_DateString, 1)
  682.   AH_Day = word(AH_DateString, 2)
  683.  
  684.  
  685.   if Highlight.AH_Month.AH_Day == '' then Highlight.AH_Month.AH_Day = AH_Event
  686.   else Highlight.AH_Month.AH_Day = Highlight.AH_Month.AH_Day'//'AH_Event
  687.   HighlightCount = HighlightCount + 1
  688.  
  689.   do AH_i = 0 to ImageClass.Count - 1
  690.     if pos(upper(ImageClass.AH_i), upper(AH_Event)) > 0 then do
  691.       Image.AH_Month.AH_Day = AH_i
  692.       ImageCount = ImageCount + 1
  693.       leave
  694.     end
  695.   end
  696.  
  697.   return 0
  698. /**/
  699.  
  700. /***//*** AssignID (AID) ***/
  701. AssignID:
  702.   parse arg AID_Var, AID_ID
  703.   interpret AID_Var' = 'AID_ID
  704.   DSR_Gad.AID_ID = AID_Var
  705.   if left(AID_Var, 3) = 'Gad' then AID_Var = 'Extra'substr(AID_Var, 5, 1)
  706.   DSR_Help.AID_ID = AID_Var'Help'
  707.  
  708.   return
  709. /**/
  710.  
  711. /***//*** AssignImage (AI) ***/
  712. AssignImage:
  713.   parse arg AI_Month, AI_Day, AI_Image
  714.  
  715.   if DoImages ~= 1 then return 0
  716.   if upper(left(AI_Month, 5)) == 'IMAGE' then do
  717.     parse var AI_Month .'.'AI_Month'.'AI_Day'='AI_Image
  718.     AI_Image = substr(AI_Image, 2, Length(AI_Image) - 2)
  719.   end
  720.  
  721.   AI_Image = strip(AI_Image, 'B', '" '||"'")
  722.   parse var AI_Image AI_Image ',' AI_DX ',' AI_DY
  723.   if (pos('/', AI_Image) == 0) & (pos(':', AI_Image) == 0) then AI_Image = ScriptDir'Images/'strip(AI_Image, 'B', ' "'||"'")
  724.   AI_DX = strip(AI_DX);if AI_DX == '' then AI_DX = 0
  725.   AI_DY = strip(AI_DY);if AI_DY == '' then AI_DY = 0
  726.   AI_DateString = DetermineDate(strip(AI_Month), strip(AI_Day), Year)
  727.   AI_Month = word(AI_DateString, 1)
  728.   AI_Day = word(AI_DateString, 2)
  729.  
  730.   if exists(AI_Image) then do
  731.     ICCount = ImageClass.Count
  732.     Image.AI_Month.AI_Day = ICCount
  733.     ImageClass.ICCount = ''
  734.     ImageFile.ICCount = AI_Image
  735.     ImageDX.ICCount = AI_DX
  736.     ImageDY.ICCount = AI_DY
  737.     ImageClass.Count = ImageClass.Count + 1
  738.   end
  739.   return 0
  740. /**/
  741.  
  742. /***//*** BoxDate (BD) ***/
  743. BoxDate:
  744.   parse arg BD_DateBoxColor
  745.  
  746.   BD_DateBoxHeight = Height.Date
  747.  
  748.   call DrawBox(BoxLeft, BoxTop, CurveOffset + 2 * Width.WidthOfDate8 + DateOffset, BD_DateBoxHeight, 'HL', BD_DateBoxColor, 0, 0, 1, CRadius)
  749.   return
  750. /**/
  751.  
  752. /***//*** BuildString (BS) ***/
  753. BuildString:
  754.   parse arg BS_String, BS_Values
  755.  
  756.   do BS_i = 1 to words(BS_Values)
  757.     InsertPos = pos('%s', BS_String)
  758.     if InsertPos == 0 then leave
  759.     interpret "BS_String = left(BS_String, InsertPos - 1)''"word(BS_Values, BS_i)"''substr(BS_String, InsertPos + 2)"
  760.   end
  761.  
  762.   return BS_String
  763. /**/
  764.  
  765. /***//*** BuryObject (BO) ***/
  766. BuryObject:
  767.   parse arg BO_Object
  768.  
  769.   if App == 'FW' then OBJECTTOBACK BO_Object
  770.   else if App == 'PGS' then do
  771.     parse arg BO_Object
  772.     SENDTOBACK OBJECTID BO_Object WINDOW winName
  773.   end
  774.  
  775.   return BO_Object
  776. /**/
  777.  
  778. /***//*** BusyReq (BR) ***/
  779. /***//*** OpenBusy ***/
  780. OpenBusy:
  781.   parse arg BR_BusyTitle, BR_EventCount
  782.  
  783.   BR_Progress = 0
  784.   if ClassAct == 1 then do
  785.     call open('ProgReq', "awnpipe:ProgressReq/xc")
  786.     call ToPIPE('ProgReq', 'm v cs si so a ps="'AppScreen'"')
  787.     call ToPIPE('ProgReq', 'label gt="'BR_BusyTitle', 'PleaseWait$'..."')
  788.     BR_ProgressGad = ToPIPE('ProgReq', 'fuelgauge defn=0 maxn='BR_EventCount' t=0 per')
  789.     call ToPIPE('ProgReq', 'layout b=0 si so cj')
  790.       call ToPIPE('ProgReq', 'space')
  791.       BR_CancelGad = ToPIPE('ProgReq', 'button pb gt="'Cancel$'"')
  792.       call ToPIPE('ProgReq', 'space')
  793.     call ToPIPE('ProgReq', 'le')
  794.     if ToPIPE('ProgReq', 'open') == 'window' then BR_ProgressWindow = 1
  795.     else BR_ProgressWindow = 0
  796.   end
  797.   else do
  798.     BR_ProgressGroup=bguivgroup(,
  799.           bguiinfo('BR_dummy',,'1B'x||'c'BR_BusyTitle', 'PleaseWait$'...')bguilayout(LGO_FixMinHeight,1)||,
  800.           bguiprogress('BR_prog2_',,0,BR_EventCount)||,
  801.           bguihgroup(,
  802.                   bguivarspace(50)bguilayout(LGO_FixMinHeight,1)||,
  803.                   bguibutton('BR_cancel_',Cancel$)bguilayout(LGO_FixMinHeight,1)||,
  804.                   bguivarspace(50)bguilayout(LGO_FixMinHeight,1),
  805.           ,,,,'W'),
  806.     ,-2,-2)
  807.     BR_ProgressWindow = bguiwindow('',BR_ProgressGroup,,2,,AppScreen)
  808.     if bguiwinopen(BR_ProgressWindow) = 0 then call Cleanup
  809.   end
  810.  
  811.   return BR_ProgressWindow
  812. /**/
  813.  
  814. /***//*** UpdateBusy ***/
  815. UpdateBusy:
  816.   parse arg BR_ReqWin, BR_ProgressMade
  817.  
  818.   if BR_ReqWin == 0 then return 0
  819.   BR_Progress = BR_Progress + BR_ProgressMade
  820. /* say '>'BR_Progress SIGL */
  821.   if ClassAct == 1 then do
  822.     if show('F', 'ProgReq') == 1 then do
  823.       call writeln('ProgReq', 'id 'BR_CancelGad' read')
  824.       BR_CancelStatus = readln('ProgReq')
  825.       if BR_CancelStatus == 1 then do
  826.         call CloseBusy('ProgReq')
  827.         return -1
  828.       end
  829.     end
  830.     else return 0
  831.     if show('F', 'ProgReq') == 1 then do
  832.       call ToPIPE('ProgReq', 'id 0 s=2')
  833.       call writeln('ProgReq', 'id 'BR_ProgressGad' defn='BR_Progress' ref')
  834.       call readln('ProgReq')
  835.     end
  836.     else return 0
  837.   end
  838.   else do
  839.     call bguiset(obj.BR_prog2_,BR_ReqWin,PROGRESS_Done,BR_Progress)
  840.     if bguiwinevent(BR_ReqWin,'ID') == id.BR_cancel_ then return -1
  841.   end
  842.  
  843.   return BR_Progress
  844. /**/
  845.  
  846. /***//*** CloseBusy ***/
  847. CloseBusy:
  848.   parse arg BR_ReqWin
  849.  
  850.   if BR_ReqWin == 0 then return 0
  851.  
  852.   if ClassAct == 1 then call close('ProgReq')
  853.   else call bguiwinclose(BR_ReqWin)
  854.   Req = 0
  855.  
  856.   return 0
  857. /**/
  858. /**/
  859.  
  860. /***//*** CalculateDate (CD) ***/
  861. CalculateDate:
  862. /* Month    is the month in which the highlight occurs                        */
  863. /* HighDate is the highest (numerical) date on which the highlight will occur */
  864. /* HighDay  is the weekday on which the month starts when HighDate will occur */
  865. /* Event    is the highlight text                                             */
  866.   parse arg CD_Month, CD_HighDay, CD_HighDate, CD_Event, CD_Color
  867.  
  868.   CD_Event = QuoteIt(CD_Event)
  869.   if CD_Month = 13 then CD_Month = Mn - 0
  870.  
  871.   if datatype(CD_HighDate) == 'CHAR' then do
  872.     CD_HighDate = upper(left(CD_HighDate, 1))
  873.     interpret 'CD_EventOffset = Day.'CD_HighDay' - StartDate'
  874.  
  875.     CD_Day  = 1 + CD_EventOffset
  876.     if CD_Day < 1 then CD_Day = CD_Day + 7
  877.  
  878.     do until CD_Day > Monthlength.Month
  879.       CD_WN = trunc((right(DateInfo('J', Year''right(CD_Month, 2, '0')''right(CD_Day, 2, '0'), 'S'), 3) - YearOffset - 1)/7 + 1)
  880.       if CD_HighDate == 'A' then call AssignHighlight(CD_Month, CD_Day, CD_Event, CD_Color)
  881.       else if (CD_HighDate == 'E') & (CD_WN//2 == 0) then call AssignHighlight(CD_Month, CD_Day, CD_Event, CD_Color)
  882.       else if (CD_HighDate == 'O') & (CD_WN//2 == 1) then call AssignHighlight(CD_Month, CD_Day, CD_Event, CD_Color)
  883.       CD_Day = CD_Day + 7
  884.     end
  885.   end
  886.   else do
  887.     interpret 'CD_HighDay = Day.'CD_HighDay
  888.     interpret 'CD_First = Day.'DateInfo('W', Year''right(CD_Month, 2, '0')'01', 'S')
  889.  
  890.     CD_Day = CD_HighDate + (CD_HighDay - CD_First)
  891.     if CD_First < CD_HighDay then CD_Day = CD_Day - 7
  892.     if CD_Event ~= '' then call AssignHighlight(CD_Month, CD_Day, CD_Event, CD_Color)
  893.   end
  894. return CD_Day
  895. /**/
  896.  
  897. /***//*** CalculateEDate (CED) ***/
  898. CalculateEDate:
  899. /* DaysPastEaster is the number of days past Easter when the event occurs */
  900. /* Event          is the highlight text                                   */
  901.   parse arg CED_DaysPastEaster, CED_EasterEvent, CED_Color
  902.  
  903.   CED_EasterEvent = '"'CED_EasterEvent'"'
  904.   CED_EasterEventDate = DateInfo('S', EasterSerial + CED_DaysPastEaster, 'I')
  905.   CED_EasterEventMonth = strip(substr(CED_EasterEventDate, 5, 2), 'L', '0')
  906.   CED_EasterEventDay = strip(right(CED_EasterEventDate, 2), 'L', '0')
  907.   call AssignHighlight(CED_EasterEventMonth, CED_EasterEventDay, CED_EasterEvent, CED_Color)
  908. return 0
  909. /**/
  910.  
  911. /***//*** CalculateImage (CI) ***/
  912. CalculateImage:
  913. /* Month    is the month in which the highlight occurs                        */
  914. /* HighDate is the highest (numerical) date on which the highlight will occur */
  915. /* HighDay  is the weekday on which the month starts when HighDate will occur */
  916. /* Event    is the highlight text                                             */
  917.   parse arg CI_Month, CI_HighDay, CI_HighDate, CI_Image
  918.  
  919.   if DoImages ~= 1 then return 0
  920.  
  921.   if CI_Month = 13 then CI_Month = Mn - 0
  922.  
  923.   if datatype(CI_HighDate) == 'CHAR' then do
  924.     CI_HighDate = upper(left(CI_HighDate, 1))
  925.     interpret 'CI_EventOffset = Day.'CI_HighDay' - StartDate'
  926.  
  927.     CI_Day  = 1 + CI_EventOffset
  928.     if CI_Day < 1 then CI_Day = CI_Day + 7
  929.  
  930.     do until CI_Day > Monthlength.Month
  931.       CI_WN = trunc((right(DateInfo('J', Year''right(CI_Month, 2, '0')''right(CI_Day, 2, '0'), 'S'), 3) - YearOffset - 1)/7 + 1)
  932.       if CI_HighDate == 'A' then call AssignImage(CI_Month, CI_Day, CI_Image)
  933.       else if (CI_HighDate == 'E') & (CI_WN//2 == 0) then call AssignImage(CI_Month, CI_Day, CI_Image)
  934.       else if (CI_HighDate == 'O') & (CI_WN//2 == 1) then call AssignImage(CI_Month, CI_Day, CI_Image)
  935.       CI_Day = CI_Day + 7
  936.     end
  937.   end
  938.   else do
  939.     interpret 'CI_HighDay = Day.'CI_HighDay
  940.     interpret 'CI_First = Day.'DateInfo('W', Year''right(CI_Month, 2, '0')'01', 'S')
  941.  
  942.     CI_Day = CI_HighDate + (CI_HighDay - CI_First)
  943.     if CI_First < CI_HighDay then CI_Day = CI_Day - 7
  944.     if CI_Event ~= '' then call AssignImage(CI_Month, CI_Day, CI_Image)
  945.     else return CI_Day
  946.   end
  947. return 0
  948. /**/
  949.  
  950. /***//*** CAGetFile (GF) ***/
  951. CAGetFile:
  952.   parse arg GF_FileHandle, GF_GadID, GF_Title, GF_InitDir
  953.  
  954.   call writeln(GF_FileHandle,'id 'GF_GadID' gt="'GF_Title':" fn="'GF_InitDir'" s=1')
  955.   GF_GetFileResult = readln(GF_FileHandle)
  956.   parse var GF_GetFileResult GF_OK GF_Choice GF_File
  957.   if GF_Choice ~= 0 then GF_File = strip(GF_File, 'B', '" ')
  958.   else GF_File = ''
  959.  
  960.   return GF_File
  961. /**/
  962.  
  963. /***//*** CASimpleReq (CAS) ***/
  964. CASimpleReq:
  965.   parse arg CAS_Title, CAS_Msg, CAS_Time
  966.  
  967.   if CAS_Time == '' then do
  968.     CAS_Msg = translate(CAS_Msg, "'", '"')
  969.     do while pos('0a'x, CAS_Msg) > 0
  970.       CAS_Msg = left(CAS_Msg, pos('0a'x, CAS_Msg) - 1)'*n'substr(CAS_Msg, pos('0a'x, CAS_Msg) + 1)
  971.     end
  972.  
  973.     call open('Req', "awnpipe:SimpleReq/xc")
  974.     call ToPIPE('Req', '"'CAS_Title'" v db dg si so a ps="'AppScreen'"')
  975.     call ToPIPE('Req', 'label gt="'CAS_Msg'"')
  976.     call ToPIPE('Req', 'layout b=0 si so cj')
  977.       call ToPIPE('Req', 'space')
  978.       call ToPIPE('Req', 'button c gt="'OK$'"')
  979.       call ToPIPE('Req', 'space')
  980.     call ToPIPE('Req', 'le')
  981.     call ToPIPE('Req', 'open')
  982.  
  983.     do while ~eof('Req')
  984.       call readln('Req')
  985.     end
  986.     call close('Req')
  987.   end
  988.   else do
  989.     call open('Req', "awnpipe:SimpleReq/xc")
  990.     call ToPIPE('Req', 'm sk si so a ps="'AppScreen'"')
  991.     call ToPIPE('Req', 'label gt="'CAS_Msg'"')
  992.     call ToPIPE('Req', 'open')
  993.  
  994.     CAS_TickCount = 0
  995.     do until CAS_TickCount >= CAS_Time
  996.       call ToPIPE('Req', 'tick 100')
  997.       Req_EventInfo = readln('Req')
  998.       parse var Req_EventInfo Req_Event' 'Req_GadID' 'Req_GadInfo1
  999.       select
  1000.         when Req_Event == 'key' then CAS_TickCount = CAS_Time
  1001.         when Req_Event = 'tick' then CAS_TickCount = CAS_TickCount + 1
  1002.         otherwise nop
  1003.       end
  1004.     end
  1005.     call close('Req')
  1006.   end
  1007.  
  1008.   return
  1009. /**/
  1010.  
  1011. /***//*** CenterText (CT) ***/
  1012. CenterText:
  1013.   parse arg CT_id, CT_CenterPoint, CT_MaxWidth, CT_WidthPercent
  1014.  
  1015.   if App == 'FW' then do
  1016.     GETOBJECTCOORDS CT_id; Parse Var result . . CT_Text.Bottom CT_Text.Width CT_Text.Height
  1017.     if CT_MaxWidth ~= 0 then CT_Text.Width = min(CT_Text.Width, CT_MaxWidth)
  1018.     else CT_Text.Width = CT_Text.Width * CT_WidthPercent
  1019.     CT_Text.Left = CT_CenterPoint - CT_Text.Width/2
  1020.     SETOBJECTCOORDS CT_id 1 CT_Text.Left CT_Text.Bottom CT_Text.Width CT_Text.Height
  1021.   end
  1022.   else if App == 'PGS' then do
  1023.     GETTEXTOBJ POSITION CT_Text OBJECTID CT_id WINDOW winName
  1024.     CT_Text.Width = CT_Text.Right - CT_Text.Left
  1025.     if CT_MaxWidth ~= 0 then CT_Text.Width = min(CT_Text.Width, CT_MaxWidth)
  1026.     else CT_Text.Width = CT_Text.Width * CT_WidthPercent
  1027.     CT_Text.Left = CT_CenterPoint - CT_Text.Width/2
  1028.     EDITTEXTOBJ POSITION CT_Text.Left CT_Text.Top (CT_Text.Left + CT_Text.Width) CT_Text.Bottom OBJECTID CT_id WINDOW winName
  1029.   end
  1030.  
  1031.   return CT_id
  1032. /**/
  1033.  
  1034. /***//*** CheckDir (PROCEDURE) ***/
  1035. CheckDir: PROCEDURE
  1036.   parse arg Dir
  1037.  
  1038.   address command 'assign >NIL: FWC: 'Dir
  1039.   if RC == 20 then return ''
  1040.   else do
  1041.     address command 'assign >NIL: FWC:'
  1042.     return Dir
  1043.   end
  1044.  
  1045.   return
  1046. /**/
  1047.  
  1048. /***//*** Cleanup () ***/
  1049. Cleanup:
  1050.   signal off syntax
  1051.   DoingCleanup = 1
  1052.   call close('DataFile')
  1053.   call close('CA')
  1054.  
  1055.   call CloseBusy(Req)
  1056.  
  1057.   if App == 'FW' then do
  1058.     SELECTOBJECT
  1059.     VIEW FinalView
  1060.     if VariablesSet == 1 then do
  1061.       interpret UserPrefs
  1062.       if upper(DecimalFormat) = 'COMMA' then DOCITEMPREFS DECIMAL Comma
  1063.     end
  1064.   end
  1065.   else if App == 'PGS' then do
  1066.     if VariablesSet == 1 then interpret UserPrefs
  1067.     LOCKINTERFACE FALSE
  1068.     LOADSETTINGS default
  1069.     REFRESH ON
  1070.     REFRESHWINDOW WINDOW winName
  1071.     DISPLAY SCALE FinalView WINDOW winName
  1072.     DISPLAY PAGE 1
  1073.     REVEALWINDOW ALL
  1074.   end
  1075.  
  1076.   if (ErrorCount == 0) & (CalType < 3) & (LaunchM ~= '') then interpret LaunchM
  1077.   if (ErrorCount == 0) & (CalType == 3) & (LaunchY ~= '') then interpret LaunchY
  1078.  
  1079.   LogOpen = open('FWCLog', Storage'FWCLog.txt', 'W')
  1080.   if LogOpen == 0 then do
  1081.     address command 'makedir >NIL: 'left(Storage, length(Storage) - 1)
  1082.     LogOpen = open('FWCLog', Storage'FWCLog.txt', 'W')
  1083.   end
  1084.   if LogOpen == 1 then OutType = 'File'
  1085.  
  1086.   if ((WarningCount > 0) | (ErrorCount > 0)) & (LogOpen == 0) then do
  1087.     LogOpen = 1
  1088.     call open('FWCLog', 'CON:10/10/500/300/FWCalendar.rexx Message/WAIT/CLOSE')
  1089.     OutType = 'CON'
  1090.   end
  1091.  
  1092.   if LogOpen == 1 then do
  1093.     call writeln('FWCLog', '      Macro: 'strip(substr(sourceline(4), pos(':', sourceline(4)) + 1)))
  1094.     call writeln('FWCLog', 'Application: 'NameAndVersion)
  1095.     call writeln('FWCLog', 'Current Dir: 'CurrentDir)
  1096.     call writeln('FWCLog', ' Script Dir: 'ScriptDir)
  1097.     call writeln('FWCLog', '       Host: 'CallHost)
  1098.     call writeln('FWCLog', '   Calendar: 'Calendar||'0a'x)
  1099.  
  1100.     interpret 'address command "version >PIPE:FWC"'
  1101.     Ln = ReadFile('PIPE:FWC')
  1102.     KS  = strip(word(Ln, 2), 'B', ' ,')
  1103.     WB  = strip(word(Ln, 4))
  1104.  
  1105.     interpret 'address command "cpu >PIPE:FWC"'
  1106.     CPULn = ReadFile('PIPE:FWC')
  1107.     CPU = strip(word(CPULn, 2))
  1108.  
  1109.     interpret 'address command "avail >PIPE:FWC"'
  1110.     AvailLn = ReadFile('PIPE:FWC')
  1111.     call OpenV('AvailLn')
  1112.       call readvln('AvailLn')
  1113.       ChipRAM = strip(word(readvln('AvailLn'), 2))
  1114.       FastRAM = strip(word(readvln('AvailLn'), 2))
  1115.     call CloseV('AvailLn')
  1116.     MaxLen  = max(length(ChipRAM), length(FastRAM))
  1117.  
  1118.     call writeln('FWCLog', '  Kickstart: 'KS)
  1119.     call writeln('FWCLog', '  Workbench: 'WB)
  1120.     call writeln('FWCLog', '        CPU: 'CPU)
  1121.     call writeln('FWCLog', '   Chip RAM: 'right(ChipRAM, MaxLen)' available')
  1122.     call writeln('FWCLog', '   Fast RAM: 'right(FastRAM, MaxLen)' available')
  1123.  
  1124.     if AL_LibCount > 0 then do
  1125.       call writeln('FWCLog', '  Libraries: 'left(Library.Name.1, 21)'v'Library.Version.1)
  1126.       do i = 2 to AL_LibCount
  1127.         call writeln('FWCLog', '             'left(Library.Name.i, 21)'v'Library.Version.i)
  1128.       end
  1129.       call writeln('FWCLog', '')
  1130.     end
  1131.     else call writeln('FWCLog', '0a'x||'No libraries added.')
  1132.  
  1133.     if AWNPipeMessage ~= '' then call writeln('FWCLog', AWNPipeMessage)
  1134.     if ClassActMessage ~= '' then call writeln('FWCLog', ClassActMessage)
  1135.     call writeln('FWCLog', '')
  1136.   end
  1137.  
  1138.   if (ErrorCount > 0) | (WarningCount > 0) | (InformationCount > 0) then do
  1139.     do i = 1 to ErrorCount
  1140.       call writeln('FWCLog', 'Error: 'Error.i)
  1141.     end
  1142.  
  1143.     do i = 1 to WarningCount
  1144.       call writeln('FWCLog', 'Warning: 'Warning.i)
  1145.     end
  1146.  
  1147.     do i = 1 to InformationCount
  1148.       call writeln('FWCLog', 'Information: 'Information.i)
  1149.     end
  1150.  
  1151.     if (ErrorCount > 0) | (WarningCount > 0) then do
  1152.       if PrefsFile ~= 'Default' then do
  1153.         if (exists(PrefsFile)) & (length(ReadFile(PrefsFile)) > 2) then do
  1154.           call writeln('FWCLog', '0a'x||' -- 'PrefsFile' -- ')
  1155.           if open('DataFile', PrefsFile) then do
  1156.             do until eof('DataFile')
  1157.               if ~eof('DataFile') then do
  1158.                 Ln = ReadLn('DataFile')
  1159.                 call writeln('FWCLog', Ln)
  1160.               end
  1161.             end
  1162.             call close('DataFile')
  1163.           end
  1164.         end
  1165.       end
  1166.  
  1167.       if ErrorCount > 0 then ErrorType = Critical$
  1168.       else ErrorType = Noncritical$
  1169.       FileMsg = ErrorType' ... 'See$' 'Storage'FWCLog.txt 'ForDetails$'.'||'0a'x||ForwardLog$': Ron Goertz <goertz@earthlink.net>'||'0a'x||Unable$
  1170.       Conbgui = ErrorType' ... 'SeeShell$'.'||'0a'x||ForwardContent$||'0a'x||'Ron Goertz <goertz@earthlink.net>'||'0a'x||Unable$
  1171.       ConCon  = ErrorType' ... 'SeeOutput$'.'||'0a'x||ForwardContent$||'0a'x||'Ron Goertz <goertz@earthlink.net>'||'0a'x||Unable$
  1172.       if (OutType == 'File') & (ClassAct == 1) then call CASimpleReq('FWCalendar 'Notice$, FileMsg)
  1173.       if (OutType == 'File') & (bguiopen == 1) then call bguireq('1B'x||'c'FileMsg,'*'OK$,'FWCalendar 'Notice$,,AppScreen)
  1174.       if (OutType == 'File') & (bguiopen == 0) & (ClassAct == 0) then do
  1175.         call open('CON', 'CON:10/10/500/300/FWCalendar notice/WAIT/CLOSE')
  1176.           call writeln('CON', FileMsg)
  1177.         call close('CON')
  1178.       end
  1179.  
  1180.       if (OutType == 'CON') & (ClassAct == 1) then call CASimpleReq('FWCalendar 'Notice$, Conbgui)
  1181.       if (OutType == 'CON') & (bguiopen == 1) then call bguireq('1B'x||'c'Conbgui,'*'OK$,'FWCalendar 'Notice$,,AppScreen)
  1182.       if (OutType == 'CON') & (bguiopen == 0) & (ClassAct == 0) then call Writeln('FWCLog', '0a'x||ConCon)
  1183.     end
  1184.   end
  1185.   if (ErrorCount == 0) & (WarningCount == 0) then do
  1186.     if LogOpen == 1 then call writeln('FWCLog', 'No errors.')
  1187.   end
  1188.  
  1189.   address command 'delete >NIL: 'Storage'FWC'App'Temp.txt quiet'
  1190.   address command 'delete >NIL: 'Storage'FWCTemp quiet'
  1191.   call close('FWCLog')
  1192.   if bguiopen = 1 then call bguiclose()
  1193.  
  1194.   exit
  1195. /**/
  1196.  
  1197. /***//*** ConvertChangesFile (CCF) ***/
  1198. ConvertChangesFile:
  1199.   /* Determine current prefs file */
  1200.   if length(readfile(ScriptDir'FWC.dat')) < 2 then return
  1201.  
  1202.   CCF_DataFile = ReadFile(ScriptDir'FWC.dat')
  1203.   if CCF_DataFile ~= '' then do
  1204.     call openv('CCF_DataFile')
  1205.       CCF_DataVersion = readvln('CCF_DataFile')
  1206.       PrefsFile = readvln('CCF_DataFile')
  1207.       PrefsFile = strip(substr(PrefsFile, pos('=', PrefsFile) + 1),," '")
  1208.       CCF_Data = readvch('CCF_DataFile', 65535)
  1209.     call closev('CCF_DataFile')
  1210.     call WriteFile('ENV:FWCalendar', PrefsFile, 'B')
  1211.  
  1212.     if PrefsFile ~= 'Default' then do
  1213.       /* Move translation strings to separate file */
  1214.       if open('DataFile', PrefsFile) then do
  1215.         call openv('CCF_TranslationFile')
  1216.         call openv('CCF_DataFile')
  1217.         do until eof('DataFile')
  1218.           CCF_Ln = ReadLn('DataFile')
  1219.           CCF_Var = upper(word(CCF_Ln, 1))
  1220.           if right(CCF_Var, 1) == '$' then call writevln('CCF_TranslationFile', compress(CCF_Ln, ':'))
  1221.           else call writevln('CCF_DataFile', CCF_Ln)
  1222.         end
  1223.         call closev('CCF_DataFile')
  1224.         call closev('CCF_TranslationFile')
  1225.         call close('DataFile')
  1226.         if CCF_TranslationFile ~= '' then do
  1227.           if open('DataFile', ScriptDir'FWCTranslations.txt', 'W') then do
  1228.             call writeln('DataFile', '/* FWC Translation file v4.x */')
  1229.             call writeln('DataFile', CCF_TranslationFile)
  1230.             call close('DataFile')
  1231.             interpret ReadFile(ScriptDir'FWCTranslations.txt')
  1232.           end
  1233.           else call AddMsg('W', 'Unable to create translation file.')
  1234.         end
  1235.         if open('DataFile', PrefsFile, 'W') then do
  1236.           call writeln('DataFile', CCF_DataFile)
  1237.           call close('DataFile')
  1238.         end
  1239.         else do
  1240.           call AddMsg('E', 'Unable to re-create preference file.')
  1241.           call Cleanup
  1242.         end
  1243.       end
  1244.     end
  1245.   end
  1246.   address command 'delete >NIL: 'ScriptDir'FWC.dat'
  1247.  
  1248.   return
  1249. /**/
  1250.  
  1251. /***//*** ConvertJ (CJ) ***/
  1252. /* Routine to convert from 'J' & 'F' to normal dates obtained from the Sky & Telescope */
  1253. /* web site. The basic program from which the following was derived originally    */
  1254. /* appeared in Astronomical Computing, Sky & Telescope, May, 1984                 */
  1255. ConvertJ:
  1256.   parse arg CJ_F, CJ_J
  1257.  
  1258.   CJ_F = CJ_F + 0.5
  1259.   if CJ_F >= 1 then do
  1260.     CJ_F = CJ_F - 1
  1261.     CJ_J = CJ_J + 1
  1262.   end
  1263.   CJ_A1 = trunc((CJ_J / 36524.25) - 51.12264)
  1264.   CJ_A = CJ_J + 1 + CJ_A1 - trunc(CJ_A1 / 4)
  1265.   CJ_B = CJ_A + 1524
  1266.   CJ_C = trunc((CJ_B / 365.25) - 0.3343)
  1267.   CJ_D = trunc(365.25 * CJ_C)
  1268.   CJ_E = trunc((CJ_B - CJ_D) / 30.61)
  1269.   CJ_D = CJ_B - CJ_D - trunc(30.61 * CJ_E) + CJ_F
  1270.   CJ_M = CJ_E - 1
  1271.   CJ_Y = CJ_C - 4716
  1272.   IF CJ_E > 13.5 then CJ_M = CJ_M - 12
  1273.   IF CJ_M < 2.5 then CJ_Y = CJ_Y + 1
  1274.   CJ_Day = trunc(CJ_D)
  1275.  
  1276.   return right(CJ_Y, 4, '0')' 'right(CJ_M, 2, '0')' 'right(CJ_Day, 2, '0')' 'CJ_D - CJ_Day
  1277. /**/
  1278.  
  1279. /***//*** ControlMX (CM) ***/
  1280. ControlMX:
  1281.   parse arg CM_SourceGrp, CM_SourcePosn
  1282.  
  1283.   DSR_Sel.CM_SourceGrp = CM_SourcePosn
  1284.   if DSR_Sel.CM_SourceGrp == DSR_PSel.CM_SourceGrp then do
  1285.     if ClassAct == 1 then call ToPIPE('CA', 'id 'Gad.CM_SourceGrp.CM_SourcePosn' s=1 page='ClickTab' refresh')
  1286.     return
  1287.   end
  1288.  
  1289.   CM_PSelect = DSR_PSel.CM_SourceGrp
  1290.   CM_Select  = DSR_Sel.CM_SourceGrp
  1291.   GadSel.CM_SourceGrp.CM_PSelect = 0
  1292.   GadSel.CM_SourceGrp.CM_Select  = 1
  1293.   if ClassAct == 1 then call ToPIPE('CA', 'id 'Gad.CM_SourceGrp.CM_PSelect' s=0 page='ClickTab' refresh')
  1294.  
  1295.   do CM_DestGrp = 0 to GroupCount
  1296.     /* nop for source group */
  1297.     if CM_DestGrp == CM_SourceGrp then iterate
  1298.  
  1299.     if CM_PSelect ~= 0 then do
  1300.       /* Update enables in disable string */
  1301.       DSR_Dis.CM_DestGrp = overlay(substr(DSR_Dis.CM_DestGrp, CM_PSelect + 1, 1) - 1, DSR_Dis.CM_DestGrp, CM_PSelect + 1)
  1302.       do CM_i = 1 to MXPairCount
  1303.         if (substr(word(MXPair.CM_i, 1), CM_SourceGrp + 1, 1) == '1') & (substr(word(MXPair.CM_i, 1), CM_DestGrp + 1, 1) == '1') then do
  1304.           call CM_SetDisables(CM_PSelect, word(MXPair.CM_i, 2), word(MXPair.CM_i, 3), 'Enable')
  1305.           call CM_SetDisables(CM_PSelect, word(MXPair.CM_i, 3), word(MXPair.CM_i, 2), 'Enable')
  1306.         end
  1307.       end
  1308.     end
  1309.  
  1310.     if CM_Select ~= 0 then do
  1311.       /* Update disables in disable string */
  1312.       DSR_Dis.CM_DestGrp = overlay(substr(DSR_Dis.CM_DestGrp, CM_Select + 1, 1) + 1, DSR_Dis.CM_DestGrp, CM_Select + 1)
  1313.       do CM_i = 1 to MXPairCount
  1314.         if (substr(word(MXPair.CM_i, 1), CM_SourceGrp + 1, 1) == '1') & (substr(word(MXPair.CM_i, 1), CM_DestGrp + 1, 1) == '1') then do
  1315.           call CM_SetDisables(CM_Select, word(MXPair.CM_i, 2), word(MXPair.CM_i, 3), 'Disable')
  1316.           call CM_SetDisables(CM_Select, word(MXPair.CM_i, 3), word(MXPair.CM_i, 2), 'Disable')
  1317.         end
  1318.       end
  1319.     end
  1320.   end
  1321.  
  1322.   /* Update previous select posn */
  1323.   DSR_PSel.CM_SourceGrp = DSR_Sel.CM_SourceGrp
  1324.  
  1325.   do CM_Grp = 0 to GroupCount
  1326.     do forever
  1327.       /* Determine differences between previous- and current-disable strings */
  1328.       /* -1 means strings are the same */
  1329.       comp = compare(DSR_Dis.CM_Grp, DSR_PDis.CM_Grp) - 1
  1330.       if comp > -1 then do
  1331.         /* Make change to GUI */
  1332.         GadDis.CM_Grp.comp = substr(DSR_Dis.CM_Grp, comp + 1, 1)
  1333.         if ClassAct == 1 then do
  1334.           if datatype(Gad.CM_Grp.comp) == 'NUM' then call ToPIPE('CA', 'id 'Gad.CM_Grp.comp' dis='substr(DSR_Dis.CM_Grp, comp + 1, 1)' page='ClickTab' refresh')
  1335.         end
  1336.         else do
  1337.           CM_Action = sign(substr(DSR_Dis.CM_Grp, comp + 1, 1))
  1338.           interpret 'call bguiset('grp.CM_Grp',winID,'Action.CM_Action',comp)'
  1339.         end
  1340.         /* Update previous-disable string */
  1341.         DSR_PDis.CM_Grp = overlay(substr(DSR_Dis.CM_Grp, comp + 1, 1), DSR_PDis.CM_Grp, comp + 1)
  1342.       end
  1343.       else leave
  1344.     end
  1345.   end
  1346.  
  1347.   return
  1348.  
  1349. /***//*** CM_SetDisables (CMSD) ***/
  1350. CM_SetDisables:
  1351.   parse arg CMSD_KeyPosn, CMSD_MX1, CMSD_MX2, CMSD_Action
  1352.  
  1353.   if upper(CMSD_Action) == 'ENABLE' then CMSD_Sign = -1
  1354.   else CMSD_Sign = 1
  1355.  
  1356.   if substr(CMSD_MX1, CMSD_KeyPosn, 1) == 1 then do
  1357.     CMSD_Posn = 0
  1358.     do CMSD_j = 1 to length(CMSD_MX2) - length(compress(CMSD_MX2, '1'))
  1359.       CMSD_Posn = pos('1', CMSD_MX2, CMSD_Posn + 1)
  1360.       /* Enable/Disable MX pairs */
  1361.       DSR_Dis.CM_DestGrp = overlay(substr(DSR_Dis.CM_DestGrp, CMSD_Posn + 1, 1) + CMSD_Sign, DSR_Dis.CM_DestGrp, CMSD_Posn + 1)
  1362.     end
  1363.   end
  1364.  
  1365.   return
  1366. /**/
  1367.  
  1368. /**/
  1369.  
  1370. /***//*** DateInfo (PROCEDURE) ***/
  1371. DateInfo: PROCEDURE
  1372.   /* DateInfo('I', '19780101', 'S') = 2443510  */
  1373.   /* Date('I', '19780101', 'S') = 0            */
  1374.   /* Option 'C' returns days since Jan 1, xx00 */
  1375.   parse arg Option, Date, Format
  1376.  
  1377.   if Option == '' then Option = 'N'
  1378.   if Date == '' then do
  1379.     Date = Date('S')
  1380.     Format = 'S'
  1381.   end
  1382.  
  1383.   Option = upper(left(Option, 1))
  1384.   Format = upper(left(Format, 1))
  1385.   if (Format == 'I') | (Format = '') then do
  1386.     Format = 'I'
  1387.  
  1388.     /* Routine to convert from a serial date to year/month/day obtained from the        */
  1389.     /* Sky & Telescope web site. The basic program from which the following was         */
  1390.     /* derived originally appeared in Astronomical Computing, Sky & Telescope,May, 1984 */
  1391.     A1 = trunc((Date / 36524.25) - 51.12264)
  1392.     A = Date + 1 + A1 - trunc(A1 / 4)
  1393.     B = A + 1524
  1394.     C = trunc((B / 365.25) - 0.3343)
  1395.     D = trunc(365.25 * C)
  1396.     E = trunc((B - D) / 30.61)
  1397.     D = B - D - trunc(30.61 * E)
  1398.     Month = E - 1
  1399.     Year = C - 4716
  1400.     IF E > 13.5 then Month = Month - 12
  1401.     IF Month < 2.5 then Year = Year + 1
  1402.     Day = trunc(D)
  1403.     J = Date
  1404.   end
  1405.   else do
  1406.     Year  = left(Date, 4) - 0
  1407.     Month = substr(Date, 5, 2) - 0
  1408.     Day   = right(Date, 2) - 0
  1409.     /* The following two lines are modified from PerpetualCalendar.bas that */
  1410.     /* appeared in Astronomical Computing, Sky & Telescope, July, 1985      */
  1411.     Temp = 0; if Month <= 2 then Temp = -1
  1412.     J = 367*Year-trunc(7*(Year+trunc((Month + 9)/12))/4)+trunc(275*Month/9)+1721031-trunc(3*(trunc((Year+Temp)/100)+1)/4) + Day - 2
  1413.   end
  1414.  
  1415.   select
  1416.     when Option == 'B' then do
  1417.       return J - 1721060
  1418.     end
  1419.     when Option == 'C' then do
  1420.       return J + 2 - DateInfo('I', left(right(Year, 4, '0'), 2)'000101', 'S')
  1421.     end
  1422.     when (Option == 'D') | (Option == 'J') then do
  1423.       DayCount = 0
  1424.       MonthLength.1    = 31
  1425.       MonthLength.2    = 28
  1426.       MonthLength.3    = 31
  1427.       MonthLength.4    = 30
  1428.       MonthLength.5    = 31
  1429.       MonthLength.6    = 30
  1430.       MonthLength.7    = 31
  1431.       MonthLength.8    = 31
  1432.       MonthLength.9    = 30
  1433.       MonthLength.10   = 31
  1434.       MonthLength.11   = 30
  1435.       MonthLength.12   = 31
  1436.       if (Year//4 == 0 & Year//100 > 0) | Year//400 == 0 Then MonthLength.2 = 29
  1437.  
  1438.       do I = (Month - 1) to 1 by -1
  1439.         DayCount = DayCount + MonthLength.I
  1440.       end
  1441.       if Option == 'D' then return DayCount + Day
  1442.       else return right(Year, 2)''right(DayCount + Day, 3, '0')
  1443.     end
  1444.     when Option == 'E' then do
  1445.       return right(Day, 2, '0')'/'right(Month, 2, '0')'/'right(Year, 2, '0')
  1446.     end
  1447.     when Option == 'I' then return J
  1448.     when (Option == 'M') | (Option == 'N') then do
  1449.       Select
  1450.         when Month ==  1 then Month = 'January'
  1451.         when Month ==  2 then Month = 'February'
  1452.         when Month ==  3 then Month = 'March'
  1453.         when Month ==  4 then Month = 'April'
  1454.         when Month ==  5 then Month = 'May'
  1455.         when Month ==  6 then Month = 'June'
  1456.         when Month ==  7 then Month = 'July'
  1457.         when Month ==  8 then Month = 'August'
  1458.         when Month ==  9 then Month = 'September'
  1459.         when Month == 10 then Month = 'October'
  1460.         when Month == 11 then Month = 'November'
  1461.         when Month == 12 then Month = 'December'
  1462.       end
  1463.       if Option == 'M' then return Month
  1464.       else return right(Day, 2, '0')' 'left(Month, 3)' 'Year
  1465.     end
  1466.     when Option == 'O' then return right(Year, 2, '0')'/'right(Month, 2, '0')'/'right(Day, 2, '0')
  1467.     when Option == 'S' then return right(Year, 4, '0')''right(Month, 2, '0')''right(Day, 2, '0')
  1468.     when Option == 'U' then return right(Month, 2, '0')'/'right(Day, 2, '0')'/'right(Year, 2, '0')
  1469.     when Option == 'W' then do
  1470.       J = J + 1
  1471.       Weekday = J - 7 * trunc(J / 7)
  1472.       Select
  1473.         when Weekday == 0 then return 'Sunday'
  1474.         when Weekday == 1 then return 'Monday'
  1475.         when Weekday == 2 then return 'Tuesday'
  1476.         when Weekday == 3 then return 'Wednesday'
  1477.         when Weekday == 4 then return 'Thursday'
  1478.         when Weekday == 5 then return 'Friday'
  1479.         when Weekday == 6 then return 'Saturday'
  1480.       end
  1481.     end
  1482.     otherwise return 0
  1483.   end
  1484. /**/
  1485.  
  1486. /***//*** DetermineDate (DD) ***/
  1487. DetermineDate:
  1488.   parse arg DD_Month, DD_Day, DD_Year
  1489.  
  1490.   if left(DD_Day, 2) == 32 then do
  1491.     if length(DD_Day) == 2 then DD_Day = MonthLength.DD_Month
  1492.     else DD_Day = MonthLength.DD_Month''right(DD_Day, 1)
  1493.   end
  1494.  
  1495.   DD_DateString = DD_Year''right(DD_Month, 2, '0')''right(strip(DD_Day, 'T', 'PN'), 2, '0')
  1496.  
  1497.   DD_Weekday = DateInfo('W', DD_DateString, 'S')
  1498.   if (right(DD_Day, 1) == 'N') & (DD_Weekday == 'Saturday') then do
  1499.     DD_NewDay = DateInfo('S', (DateInfo('I', DD_DateString, 'S') + 2), 'I')
  1500.     DD_Month = substr(DD_NewDay, 5, 2) - 0
  1501.     DD_Day = substr(DD_NewDay, 7, 2) - 0
  1502.   end
  1503.   else if (right(DD_Day, 1) == 'P') & (DD_Weekday == 'Saturday') then do
  1504.     DD_NewDay = DateInfo('S', (DateInfo('I', DD_DateString, 'S') - 1), 'I')
  1505.     DD_Month = substr(DD_NewDay, 5, 2) - 0
  1506.     DD_Day = substr(DD_NewDay, 7, 2) - 0
  1507.   end
  1508.   else if (right(DD_Day, 1) == 'N') & (DD_Weekday == 'Sunday') then do
  1509.     DD_NewDay = DateInfo('S', (DateInfo('I', DD_DateString, 'S') + 1), 'I')
  1510.     DD_Month = substr(DD_NewDay, 5, 2) - 0
  1511.     DD_Day = substr(DD_NewDay, 7, 2) - 0
  1512.   end
  1513.   else if (right(DD_Day, 1) == 'P') & (DD_Weekday == 'Sunday') then do
  1514.     DD_NewDay = DateInfo('S', (DateInfo('I', DD_DateString, 'S') - 2), 'I')
  1515.     DD_Month = substr(DD_NewDay, 5, 2) - 0
  1516.     DD_Day = substr(DD_NewDay, 7, 2) - 0
  1517.   end
  1518.   DD_Day = strip(DD_Day, 'T', 'PN')
  1519.  
  1520.   return DD_Month' 'DD_Day
  1521. /**/
  1522.  
  1523. /***//*** DetermineHost () ***/
  1524. DetermineHost:
  1525.   owner = ReadFile('ENV:Owner')
  1526.   if (pos('FINALWRITER', CurrentDir) > 0) | (left(CallHost, 6) == 'FINALW') then do
  1527.     App     = 'FW'
  1528.     AppName = 'FINALWRITER'
  1529.     if CallHost == 'REXX' then HostPort = substr(PortList, pos('FINALW.', PortList), 8)
  1530.     else HostPort = CallHost
  1531.     address value HostPort
  1532.     if owner == 'rgoertz' then do
  1533.       if CallHost == 'REXX' then CLEARDOC FORCE
  1534.       else do
  1535.         CLEARDOC
  1536.         if result == 1 then exit
  1537.       end
  1538.     end
  1539.     else do
  1540.       CLEARDOC
  1541.       if result == 1 then exit
  1542.     end
  1543.  
  1544.     GETDOCITEMPREFS Decimal; DecimalFormat = result
  1545.     DOCITEMPREFS Decimal Period
  1546.   end
  1547.   else if (pos('PAGESTREAM', CurrentDir) > 0) | (CallHost == 'PAGESTREAM') then do
  1548.     App     = 'PGS'
  1549.     AppName = 'PAGESTREAM'
  1550.     HostPort = 'PAGESTREAM'
  1551.     address value HostPort
  1552.   end
  1553.   else do
  1554.     call AddMsg('E', 'Unable to determine host!')
  1555.     call AddMsg('E', 'Make sure FWCalendar is called from Final Writer or PageStream.')
  1556.     call Cleanup
  1557.   end
  1558.  
  1559.   NameAndVersion = getclip('FWC'App'VersionInfo.txt')
  1560.   if NameAndVersion == '' then do
  1561.     address command 'list >PIPE:FWC 'AppName'#? lformat %N'
  1562.     ListOutput = ReadFile('PIPE:FWC')
  1563.     call openv('ListOutput')
  1564.       do while ~eofv('ListOutput')
  1565.         PgmName = readvln('ListOutput')
  1566.         if pos('.', PgmName) == 0 then leave
  1567.       end
  1568.     call closev('ListOutput')
  1569.     PgmVersion = PgmVer(PgmName)
  1570.     NameAndVersion = PgmName' 'PgmVersion
  1571.  
  1572.     if PgmVersion == 'not' then do
  1573.       if App == 'FW' then do
  1574.         call open('Temp', CurrentDir''PgmName)
  1575.           /* Desired string at 325365 for v 5.06 */
  1576.           /* Desired string at 333771 for FW97   */
  1577.           FileOffset = 325300
  1578.           call seek('Temp', FileOffset, 'B')
  1579.           do until (EndPos ~= 0) | (PrevOffset = FileOffset)
  1580.             PrevOffset = FileOffset
  1581.             Chunk = readch('Temp', 10000)
  1582.             EndPos = pos('Created', Chunk)
  1583.             if EndPos == 0 then FileOffset = seek('Temp', -100, 'C')
  1584.           end
  1585.           if EndPos ~= 0 then do
  1586.             StartPos = lastpos('Final', Chunk, EndPos)
  1587.             EndPos = pos('00'x||'00'x, Chunk, StartPos)
  1588.             NameAndVersion = substr(Chunk, StartPos, EndPos - StartPos - 1)
  1589.           end
  1590.           else do
  1591.             FileOffset = 0
  1592.             call seek('Temp', FileOffset, 'B')
  1593.             do until (EndPos ~= 0) | (PrevOffset = FileOffset)
  1594.               PrevOffset = FileOffset
  1595.               Chunk = readch('Temp', 10000)
  1596.               EndPos = pos('FinalWriter 97', Chunk)
  1597.               if EndPos == 0 then FileOffset = seek('Temp', -100, 'C')
  1598.             end
  1599.             if EndPos ~= 0 then NameAndVersion = 'FinalWriter 97'
  1600.             else NameAndVersion = 'Final Writer - version unknown'
  1601.           end
  1602.         call close('Temp')
  1603.       end
  1604.       else if App == 'PGS' then do
  1605.         NameAndVersion = PgmName" - can't find version info"
  1606.       end
  1607.     end
  1608.     call setclip('FWC'App'VersionInfo.txt', NameAndVersion)
  1609.   end
  1610.   else do
  1611.     PgmName = word(NameAndVersion, 1)
  1612.     PgmVersion = subword(NameAndVersion, 2)
  1613.   end
  1614.  
  1615.   AppScreen = ''
  1616.   PubScreenApps = 'FrontPubScreen Publican MagicPubName'
  1617.   do i = 1 to words(PubScreenApps)
  1618.     interpret 'address command "'word(PubScreenApps, i)' >PIPE:FWC"'
  1619.     if RC > 0 then iterate
  1620.     AppScreen = readfile('PIPE:FWC')
  1621.     if AppScreen ~= '' then leave
  1622.   end
  1623.  
  1624.   return HostPort
  1625. /**/
  1626.  
  1627. /***//*** DoOptions (DO) ***/
  1628. DoOptions:
  1629.   if (DayType == 'Extended') & (BackgroundColor == '<'Clear$'>') then DO_PrintColor = Color.Extended
  1630.   else if (DayType == 'Extended') & (BackgroundColor ~= '<'Clear$'>') then DO_PrintColor = AltColor.Extended
  1631.  
  1632.   /***//* DoJulian & DoJulianLeft */
  1633.   if (DoJulian ~= '') | (DoJulianLeft ~= '') then do
  1634.     DO_JDay = right(DateInfo('J', JulianDay, 'I'), 3)
  1635.     if (Day <= 0) & (PrevMonth = 12) then DO_JDayLeft = right(365 + PrevLeapYear - DO_JDay, 3, '0')
  1636.     else DO_JDayLeft = right(365 + LeapYear - DO_JDay, 3, '0')
  1637.  
  1638.     if (DayType ~= 'Extended') & (BackgroundColor == '<'Clear$'>') then DO_PrintColor = Color.Julian
  1639.     else if (DayType ~= 'Extended') & (BackgroundColor ~= '<'Clear$'>') then DO_PrintColor = AltColor.Julian
  1640.  
  1641.     if DoJulian ~= '' then do
  1642.       DO_Text2Print = Text.Julian''DO_JDay
  1643.       if DoJulianLeft == DoJulian then DO_Text2Print = DO_Text2Print'/'DO_JDayLeft
  1644.       JID.Day = PrintOption(DoJulian)
  1645.     end
  1646.  
  1647.     if (DoJulianLeft ~= '') & (DoJulianLeft ~= DoJulian) then do
  1648.       DO_Text2Print = DO_JDayLeft
  1649.       JIDL.Day = PrintOption(DoJulianLeft)
  1650.     end
  1651.   end
  1652.   /**/
  1653.  
  1654. /***//* DoSunrise & DoSunset */
  1655.   if (DoSunRise ~= '') | (DoSunSet ~= '') then do
  1656.     SRSS$ = GetSRSS(JulianDay)
  1657.  
  1658.     if DoSunRise ~= '' then do
  1659.       if (DayType ~= 'Extended') & (BackgroundColor == '<'Clear$'>') then DO_PrintColor = Color.Sunrise
  1660.       else if (DayType ~= 'Extended') & (BackgroundColor ~= '<'Clear$'>') then DO_PrintColor = AltColor.Sunrise
  1661.       DO_Text2Print = Text.Sunrise''word(SRSS$, 1)
  1662.       if DoSunSet == DoSunRise then DO_Text2Print = DO_Text2Print'/'word(SRSS$, 3)
  1663.       SRID.Day = PrintOption(DoSunRise)
  1664.     end
  1665.  
  1666.     if (DoSunSet ~= '') & (DoSunSet ~= DoSunRise) then do
  1667.       if (DayType ~= 'Extended') & (BackgroundColor == '<'Clear$'>') then DO_PrintColor = Color.Sunset
  1668.       else if (DayType ~= 'Extended') & (BackgroundColor ~= '<'Clear$'>') then DO_PrintColor = AltColor.Sunset
  1669.       DO_Text2Print = Text.Sunset''word(SRSS$, 3)
  1670.       SSID.Day = PrintOption(DoSunSet)
  1671.     end
  1672.   end
  1673.   /**/
  1674.  
  1675. /***//* DoWeekNumber */
  1676.   if (DoWeekNumber ~= '') & (CurrentColumn = 0) then do
  1677.     if (DayType ~= 'Extended') & (BackgroundColor == '<'Clear$'>') then DO_PrintColor = Color.WeekNumber
  1678.     else if (DayType ~= 'Extended') & (BackgroundColor ~= '<'Clear$'>') then DO_PrintColor = AltColor.WeekNumber
  1679.     DO_WN = trunc((right(DateInfo('J', JulianDay, 'I'), 3) - YearOffset - 1)/7 + 1)
  1680.     DO_Text2Print = Text.WeekNumber''DO_WN
  1681.     WNID.Day = PrintOption(DoWeekNumber)
  1682.   end
  1683.   /**/
  1684.  
  1685.   /***//* DoImages */
  1686.   if DoImages == 1 then do
  1687.     if Image.Month.Day ~= '' then do
  1688.       ImageNumber = Image.Month.Day
  1689.       ImageDX = ImageDX.ImageNumber
  1690.       ImageDY = ImageDY.ImageNumber
  1691.       if ImageType.ImageNumber == '' then do
  1692.         DO_Cmd = Storage''GfxApp' >PIPE:FWC '
  1693.         DO_InsertPos = pos('%s', GfxCmd)
  1694.         DO_Cmd = DO_Cmd''left(GfxCmd, DO_InsertPos - 1)''ImageFile.ImageNumber''substr(GfxCmd, DO_InsertPos + 2)
  1695.         address command DO_Cmd
  1696.         DO_Template = GfxTemplate
  1697.         DO_InfoLine = ReadFile('PIPE:FWC')
  1698.         if DO_InfoLine ~= '' then do
  1699.           interpret "parse var DO_InfoLine "DO_Template
  1700.           DO_ImageType = upper(strip(ImgDT))
  1701.           DO_Width = strip(ImgWidth)
  1702.           DO_Height = strip(ImgHeight)
  1703.           if (datatype(DO_ImageType) ~= 'CHAR') | (datatype(DO_Width) ~= 'NUM') | (datatype(DO_Height) ~= 'NUM') then do
  1704.             call AddMsg('W', DO_InfoLine)
  1705.             Image.Month.Day = ''
  1706.           end
  1707.           else do
  1708.             ImageType.ImageNumber = DO_ImageType
  1709.             if DO_ImageType ~= 'POST' then do
  1710.               ImageWidth.ImageNumber = DO_Width / 72
  1711.               ImageHeight.ImageNumber = DO_Height / 72
  1712.               if (ImageWidth.ImageNumber > (BoxWidth * MaxImgWidth)) | (ImageHeight.ImageNumber > (BHeight * MaxImgHeight)) then do
  1713.                 EnlFactor = max(ImageWidth.ImageNumber / (BoxWidth * MaxImgWidth), ImageHeight.ImageNumber / (BHeight * MaxImgHeight))
  1714.                 ImageWidth.ImageNumber  = ImageWidth.ImageNumber / EnlFactor
  1715.                 ImageHeight.ImageNumber = ImageHeight.ImageNumber / EnlFactor
  1716.               end
  1717.             end
  1718.           end
  1719.         end
  1720.       end
  1721.  
  1722.       if ImageType.ImageNumber ~= '' then do
  1723.         if App == 'FW' then do
  1724.           if ImageWidth.ImageNumber == 0 then do
  1725.             INSERTIMAGE ImageFile.ImageNumber POSITION 1 '-1' '-1' '-1' '-1'
  1726.             ImageID.Day = result
  1727.             GETOBJECTCOORDS ImageID.Day
  1728.             parse var result . . . ImageWidth.ImageNumber ImageHeight.ImageNumber
  1729.             if (ImageWidth.ImageNumber > (BoxWidth * MaxImgWidth)) | (ImageHeight.ImageNumber > (BHeight * MaxImgHeight)) then do
  1730.               EnlFactor = max(ImageWidth.ImageNumber / (BoxWidth * MaxImgWidth), ImageHeight.ImageNumber / (BHeight * MaxImgHeight))
  1731.               ImageWidth.ImageNumber  = ImageWidth.ImageNumber / EnlFactor
  1732.               ImageHeight.ImageNumber = ImageHeight.ImageNumber / EnlFactor
  1733.             end
  1734.             DELETEOBJECT ImageID.Day
  1735.           end
  1736.           Image.Left = BoxLeft + (BoxWidth - ImageWidth.ImageNumber)/2 + ImageDX
  1737.           Image.Top  = BoxTop + (BHeight - ImageHeight.ImageNumber)/2 + ImageDY
  1738.           INSERTIMAGE ImageFile.ImageNumber POSITION 1 Image.Left Image.Top ImageWidth.ImageNumber ImageHeight.ImageNumber
  1739.           ImageID.Day = result
  1740.           OBJECTTOBACK ImageID.Day
  1741.         end
  1742.         else if App == 'PGS' then do
  1743.           DO_ImgType = ImageType.ImageNumber
  1744.           if PGSFilter.DO_ImgType == '' then PGSFilter.DO_ImgType = DO_ImgType
  1745.           if ImageWidth.ImageNumber == 0 then do
  1746.             PLACEGRAPHIC FILE ImageFile.ImageNumber FILTER PGSFilter.DO_ImgType WINDOW winName
  1747.             ImageID.Day = result
  1748.             if ImageType.ImageNumber == 'POST' then GETDRAWING POSITION Image OBJECTID ImageID.Day WINDOW winName
  1749.             else GETPICTURE POSITION Image OBJECTID ImageID.Day WINDOW winName
  1750.             DELETEOBJECT OBJECTID ImageID.Day WINDOW winName
  1751.             ImageWidth.ImageNumber = Image.Right - Image.Left
  1752.             ImageHeight.ImageNumber = Image.Bottom - Image.Top
  1753.             if (ImageWidth.ImageNumber > (BoxWidth * MaxImgWidth)) | (ImageHeight.ImageNumber > (BHeight * MaxImgHeight)) then do
  1754.               EnlFactor = max(ImageWidth.ImageNumber / (BoxWidth * MaxImgWidth), ImageHeight.ImageNumber / (BHeight * MaxImgHeight))
  1755.               ImageWidth.ImageNumber  = ImageWidth.ImageNumber / EnlFactor
  1756.               ImageHeight.ImageNumber = ImageHeight.ImageNumber / EnlFactor
  1757.             end
  1758.           end
  1759.           Image.Left = BoxLeft + (BoxWidth - ImageWidth.ImageNumber)/2 + ImageDX
  1760.           Image.Top  = BoxTop + (BHeight - ImageHeight.ImageNumber)/2 + ImageDY
  1761.           PLACEGRAPHIC FILE ImageFile.ImageNumber FILTER PGSFilter.DO_ImgType AT Image.Left Image.Top WINDOW winName
  1762.           ImageID.Day = result
  1763.           if ImageType.ImageNumber == 'POST' then EDITDRAWING POSITION Image.Left Image.Top (Image.Left + ImageWidth.ImageNumber) (Image.Top + ImageHeight.ImageNumber) OBJECTID ImageID.Day WINDOW winName
  1764.           else EDITPICTURE POSITION Image.Left Image.Top (Image.Left + ImageWidth.ImageNumber) (Image.Top + ImageHeight.ImageNumber) OBJECTID ImageID.Day WINDOW winName
  1765.           SENDTOBACK OBJECTID ImageID.Day WINDOW winName
  1766.         end
  1767.       end
  1768.     end
  1769.   end
  1770.   /**/
  1771.  
  1772. /***//* DoPhases */
  1773.   if Day < 1 then do
  1774.     DO_PrintColor = Color.Extended
  1775.     DO_MoonMonth = PrevMonth
  1776.     DO_MoonYear = PrevYear
  1777.   end
  1778.   else if Day > MonthLength.Month then do
  1779.     DO_PrintColor = Color.Extended
  1780.     DO_MoonMonth = NextMonth
  1781.     DO_MoonYear = NextYear
  1782.   end
  1783.   else do
  1784.     DO_PrintColor = Color.Moon
  1785.     DO_MoonMonth = Month
  1786.     DO_MoonYear = EnteredYear
  1787.   end
  1788.   if (DoPhases ~= '') & (MoonPhase.DO_MoonYear.DO_MoonMonth.PrintDay ~= '') then do
  1789.     select
  1790.       when right(DoPhases, 1) == 'L' then DO_MoonLeft = BoxLeft + (MoonRadius * 1.2)
  1791.       when right(DoPhases, 1) == 'C' then DO_MoonLeft = BoxLeft + BoxWidth / 2
  1792.       when right(DoPhases, 1) == 'R' then DO_MoonLeft = BoxLeft + BoxWidth - (MoonRadius * 1.2)
  1793.     end
  1794.     if left(DoPhases, 1) == 'T' then DO_DX = MoonRadius * 1.2
  1795.     else if left(DoPhases, 1) == 'B' then DO_DX = BHeight - (MoonRadius * 1.2)
  1796.     MoonID.Day = DrawMoon(MoonPhase.DO_MoonYear.DO_MoonMonth.PrintDay, DO_MoonLeft, BoxTop + DO_DX, DO_PrintColor)
  1797.     if left(DoPhases, 1) == 'T' then MoonID.Day = 0
  1798.   end
  1799.   /**/
  1800.  
  1801. /***//* DoHistory */
  1802.   if DoHistory ~= 0 then do
  1803.     DO_Start = pos('|'||PrintDay, RandomFile)
  1804.     if DO_Start ~= 0 then do
  1805.       DO_End = pos('|'||'0a'x, RandomFile, DO_Start)
  1806.       if DO_End == 0 then DO_End = length(RandomFile)
  1807.       DO_RandomFile = substr(RandomFile, DO_Start, DO_End - DO_Start - 1)
  1808.       RandomCount = length(DO_RandomFile) - length(compress(DO_RandomFile, '|'))
  1809.       if RandomCount == 1 then RandomLine = 1
  1810.       else RandomLine = trunc(randu(time(s)*date('I')) * RandomCount) + 1
  1811.       call openv('DO_RandomFile')
  1812.       if RandomLine > 1 then call readvln('DO_RandomFile', RandomLine - 1)
  1813.       call PrintHighlight(strip(substr(readvln('DO_RandomFile'), 4)), 'History')
  1814.       call closev('DO_RandomFile')
  1815.     end
  1816.   end
  1817. /**/
  1818.  
  1819. /***//* DoRandom */
  1820.   if DoRandom ~= 0 then do
  1821.     if RandomCount >= Monthlength.Month then do
  1822.       do until pos('|'RandomLine'|', UsedRandoms) == 0
  1823.         RandomLine = trunc(randu(time(s)*date('I')) * RandomCount) + 1
  1824.       end
  1825.       UsedRandoms = UsedRandoms'|'RandomLine'|'
  1826.     end
  1827.     else RandomLine = trunc(randu(time(s)*date('I')) * RandomCount) + 1
  1828.     call seekv('RandomFile', 0, 'B')
  1829.     if RandomLine > 1 then call readvln('RandomFile', RandomLine - 1)
  1830.     call PrintHighlight(substr(readvln('RandomFile'), 2), 'Random')
  1831.   end
  1832. /**/
  1833.  
  1834.   return
  1835. /**/
  1836.  
  1837. /***//*** DoSetupReq_BGUI () ***/
  1838. DoSetupReq_BGUI:
  1839.   grp.0 = 'obj.bottomleft_'
  1840.   grp.1 = 'obj.bottomcenter_'
  1841.   grp.2 = 'obj.bottomright_'
  1842.   grp.3 = 'obj.topcenter_'
  1843.   grp.4 = 'obj.topright_'
  1844.  
  1845.   Action.0 = 'MX_EnableButton'
  1846.   Action.1 = 'MX_DisableButton'
  1847.  
  1848.   DoBothS  = ''
  1849.   DoBothJ  = ''
  1850.  
  1851.   UCMN = upper(CurrentMiscName)
  1852.   if (UCMN == 'GFXAPPPATH') | (UCMN == 'SUNCALCPATH') | (UCMN == 'GFXAPP') then VarReqGad = 1
  1853.   else VarReqGad = 0
  1854.  
  1855.   if (PrefsName == 'Default') & (PrefsFile ~= 'Default') then DisplayName = PrefsFile
  1856.   else DisplayName = PrefsName
  1857.  
  1858.   do DSR_Posn = 1 + (PhaseLib ~= 1) to 5 + 3 * exists(Storage'suncalc')
  1859.     interpret 'DoVariable = "Do'Do.DSR_Posn'"'
  1860.     if value(DoVariable) == 0 then interpret DoVariable " = ''"
  1861.     if value(DoVariable) ~= '' then do
  1862.       interpret DoVariable' = right(value(DoVariable), 2, "B")'
  1863.       DSR_Grp = translate(left(value(DoVariable), 1), '02', 'BT') + translate(right(value(DoVariable), 1), '012', 'LCR')
  1864.       GadSel.DSR_Grp.DSR_Posn = 1
  1865.       DSR_Sel.DSR_Grp = DSR_Posn
  1866.     end
  1867.   end
  1868.  
  1869.   do DSR_Grp = 0 to GroupCount
  1870.     if (GadSel.DSR_Grp.SunsetPosn == GadSel.DSR_Grp.SunrisePosn) & (GadSel.DSR_Grp.SunsetPosn == 1) then do
  1871.        GadSel.DSR_Grp.SunsetPosn  = 0
  1872.        GadSel.DSR_Grp.SunrisePosn = 0
  1873.        GadSel.DSR_Grp.BothSPosn   = 1
  1874.        DSR_Sel.DSR_Grp = BothSPosn
  1875.     end
  1876.     else if (GadSel.DSR_Grp.JulianPosn == GadSel.DSR_Grp.JulianLeftPosn) & (GadSel.DSR_Grp.JulianPosn == 1) then do
  1877.        GadSel.DSR_Grp.JulianPosn     = 0
  1878.        GadSel.DSR_Grp.JulianLeftPosn = 0
  1879.        GadSel.DSR_Grp.BothJPosn      = 1
  1880.        DSR_Sel.DSR_Grp = BothJPosn
  1881.     end
  1882.   end
  1883.  
  1884.   call bguilist('monthlist_',January$,February$,March$,April$,May$,June$,July$,August$,September$,October$,November$,December$)
  1885.   call bguilist('mxopts_',None$,Phases$,Weeknumber$,Julian$,JulLeft$,JulJulLeft$,Sunrise$,Sunset$,RiseSet$)
  1886.   call bguilist('mxopts2_',None$,Phases$,Weeknumber$,Julian$,JulLeft$,JulJulLeft$,Sunrise$,Sunset$,RiseSet$,History$,Random$)
  1887.   if App == 'FW' then do
  1888.     call bguilist('calendartypelist_',SingleMonth$,WholeYear$)
  1889.     MonthYearGads = bguihgroup(,
  1890.       bguicycle('monthchoice_',,'monthlist_','P')bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1)||,
  1891.       bguistring('yearchoice_',,Year,5)bguilayout(LGO_FixMinHeight, 1))
  1892.   end
  1893.   else do
  1894.     call bguilist('calendartypelist_',SingleMonth$,MultiMonth$,WholeYear$)
  1895.     MonthYearGads = bguihgroup(,
  1896.       bguicycle('monthchoice_',,'monthlist_','P')bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1)||,
  1897.       bguicycle('endmonthchoice_',,'monthlist_','P')bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1)||,
  1898.       bguistring('yearchoice_',,Year,5)bguilayout(LGO_FixMinHeight, 1))
  1899.   end
  1900.  
  1901.   /***//*** GUI Description ***/
  1902.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  1903.   g=bguivgroup(,
  1904.     bguiinfo('dummy_',,esc||'c'DisplayName)bguilayout(LGO_FixMinHeight, 1)||,
  1905.     bguimx('mainswitcher_',,bguilist('mainpnames_',OptLayout$,Variables$,Top$,Bottom$),'T')bguilayout(LGO_FixMinHeight,1)||,
  1906.     bguipages('mainpages_',,
  1907.       bguivgroup(,
  1908.         bguihgroup(,
  1909.           bguivgroup(,
  1910.             bguicheckbox('minicals_',MiniCals$, DoMiniCals)bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1)||,
  1911.             bguicheckbox('highlights_',Highlights$, DoHighlights)bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1)||,
  1912.             bguicheckbox('images_',Images$, DoImages)bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1)||,
  1913.             bguicheckbox('dateboxes_',BoxDates$, DoDateBox)bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1),
  1914.           )||,
  1915.           bguivarspace(10)||,
  1916.           bguivgroup(,
  1917.             bguicheckbox('extended_',Extended$, DoExtended)bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1)||,
  1918.             bguicheckbox('toplong_',TopLong$, DoTopExtraWk)bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1)||,
  1919.             bguicheckbox('notebox_',NoteBox$, DoNoteBox)bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1),
  1920.           ),
  1921.         ,-2,'F',Options$)||,
  1922.         bguivgroup(,
  1923.           bguihgroup(,
  1924.             bguivarspace(40)||,
  1925.             bguistring('topmargin_',,Margin.Top,8)bguilayout(LGO_FixMinHeight, 1)bguilayout(LGO_Weight,20)||,
  1926.             bguivarspace(40),
  1927.           )||,
  1928.           bguihgroup(,
  1929.             bguivarspace(20)||,
  1930.             bguistring('leftmargin_',,Margin.Left,8)bguilayout(LGO_FixMinHeight, 1,LGO_Weight,20)||,
  1931.             bguicycle('orientation_',,bguilist('orientlist_',Wide$,Tall$))bguilayout(LGO_FixMinHeight, 1,LGO_Weight,20)||,
  1932.             bguistring('rightmargin_',,Margin.Right,8)bguilayout(LGO_FixMinHeight, 1,LGO_Weight,20)||,
  1933.             bguivarspace(20),
  1934.           )||,
  1935.           bguihgroup(,
  1936.             bguivarspace(40)||,
  1937.             bguistring('bottommargin_',,Margin.Bottom,8)bguilayout(LGO_FixMinHeight, 1,LGO_Weight,20)||,
  1938.             bguivarspace(40),
  1939.           ),
  1940.         ,-2,'F',OrientMarg$),
  1941.       )||,
  1942.       bguivgroup(,
  1943.         bguihgroup(,
  1944.           bguicycle('fontvar_',,'FontVarName','P')bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight, 1)||,
  1945.           bguistring('fontvalue_',,value(CurrentFontName),256)bguilayout(LGO_FixMinHeight,1)||,
  1946.           bguiibutton('addfont_','B','P')bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight, 1),
  1947.         ,-2,'F',Fonts$)||,
  1948.         bguivgroup(,
  1949.           bguihgroup(,
  1950.             bguicycle('colorvar_',,'ColorVarName','P')bguilayout(LGO_FixMinHeight, 1)||,
  1951.             bguicycle('colorlist_',,'ColorList','P')bguilayout(LGO_FixMinHeight, 1),
  1952.           )||,
  1953.           bguihgroup(,
  1954.             bguivarspace(1)||,
  1955.             bguicheckbox('matchcolors_',MatchColors$, DoMatchColors)bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1),
  1956.           )||,
  1957.           bguihgroup(,
  1958.             bguivarspace(1)||,
  1959.             bguicheckbox('dailycolors_',DailyColors$, DoDailyColors)bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1),
  1960.           ),
  1961.         ,-2,'F',Colors$)||,
  1962.         bguivgroup(,
  1963.           bguihgroup(,
  1964.             bguivarspace(40)||,
  1965.             bguibutton('sethighlights_',HighlightEd$)bguilayout(LGO_FixMinHeight, 1,LGO_Weight,20)||,
  1966.             bguivarspace(40),
  1967.           )||,
  1968.           bguihgroup(,
  1969.             bguicycle('currentvar_',,'MiscVarName','P')bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight, 1)||,
  1970.             bguistring('currentvalue_',,VarVal,256)bguilayout(LGO_FixMinHeight,1)||,
  1971.             bguiibutton('addvar_','B','F')bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight, 1),
  1972.           ),
  1973.         ,-2,'F',MiscVar$),
  1974.       ,-2)||,
  1975.       bguihgroup(,
  1976.         bguivarspace(40)||,
  1977.         bguivgroup(,
  1978.           bguimx('topcenter_',Top$||'0a'x||Center$,'mxopts_','R')bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1),
  1979.         ,-3,'F')||,
  1980.         bguivgroup(,
  1981.           bguimx('topright_',Top$||'0a'x||Right$,'mxopts_','R')bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1),
  1982.         ,-3,'F'),
  1983.       )||,
  1984.       bguihgroup(,
  1985.         bguivgroup(,
  1986.           bguimx('bottomleft_',Bottom$||'0a'x||Left$,'mxopts_','R')bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1),
  1987.         ,-3,'F')||,
  1988.         bguivgroup(,
  1989.           bguimx('bottomcenter_',Bottom$||'0a'x||Center$,'mxopts2_','R')bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1),
  1990.         ,-3,'F')||,
  1991.         bguivgroup(,
  1992.           bguimx('bottomright_',Bottom$||'0a'x||Right$,'mxopts_','R')bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1),
  1993.         ,-3,'F'),
  1994.       ),
  1995.     )||,
  1996.     MonthYearGads||,
  1997.     bguihgroup(,
  1998.       bguicycle('calendartype_',,'calendartypelist_','P')bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1)||,
  1999.       bguibutton('go_',Go$)bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1)||,
  2000.       bguivarspace(2)||,
  2001.       bguibutton('reset_',Reset$)bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1)||,
  2002.       bguibutton('load_',Load$)bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1)||,
  2003.       bguibutton('saveas_',SaveAs$)bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1)||,
  2004.       bguivarspace(2)||,
  2005.       bguibutton('cancel_',Cancel$)bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1),
  2006.     ),
  2007.   ,'-3','-3')
  2008.   /**/
  2009.  
  2010.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  2011.   winID=bguiwindow(VarGUITitle$,g,-1,-1,,AppScreen)
  2012.  
  2013.   if App == 'FW' then nop
  2014.   else if App == 'PGS' then do
  2015.     FontGroup=bguivgroup(bguilistview('fontlistview_',,'FontList'))
  2016.     if UpdateBusy(Req, 1) == -1 then call Cleanup
  2017.     FontwinID=bguiwindow(SelectFont$':',FontGroup,20,50,,AppScreen)
  2018.   end
  2019.  
  2020.   do DSR_Grp = 0 to GroupCount
  2021.     interpret 'call bguiset('grp.DSR_Grp',winID,MX_Active,DSR_Sel.DSR_Grp)'
  2022.     call ControlMX(DSR_Grp, DSR_Sel.DSR_Grp)
  2023.     if PhaseLib ~= 1 then interpret 'call bguiset('grp.DSR_Grp',winID,MX_DisableButton,1)'
  2024.     if ~exists(Storage'suncalc') then interpret 'call bguiset('grp.DSR_Grp',winID,MX_DisableButton,6,MX_DisableButton,7,MX_DisableButton,8)'
  2025.   end
  2026.  
  2027.   if App == 'PGS' then call bguiset(obj.endmonthchoice_, winID, GA_Disabled, 1)
  2028.   call bguiset(obj.addvar_, winID, GA_Disabled, ~VarReqGad)
  2029.   call bguiset(obj.orientation_,winID,CYC_Active,OrientChoice)
  2030.   call bguiset(obj.monthchoice_,winID,CYC_Active,CalMonth-1)
  2031.   call bguiset(obj.colorlist_,winID,CYC_Active,max(0, MemberID(Value(CurrentColorName),'ColorList')))
  2032.   CurrentColor = bguiget(obj.colorlist_, CYC_Active)
  2033.   call bguiset(obj.currentvar_,,BT_Key,'09'x)
  2034.   call bguiset(obj.currentvalue_,,BT_Key,'0d'x)
  2035.   call bguiset(obj.images_,winID,GA_Disabled,~exists(Storage''GfxApp))
  2036.   call bguiaddmap(obj.mainswitcher_,obj.mainpages_,MX_Active,PAGE_Active)
  2037.   call bguiwintabcycleorder(winID,obj.topmargin_||obj.leftmargin_||obj.rightmargin_||obj.bottommargin_)
  2038.   if DoExtended == 1 then do
  2039.     call bguiset(obj.toplong_,winID, GA_Selected, 0, GA_Disabled, 1)
  2040.     DoTopExtraWk = 0
  2041.     call bguiset(obj.notebox_,winID, GA_Selected, 0, GA_Disabled, 1)
  2042.     DoNoteBox = 0
  2043.   end
  2044.  
  2045.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  2046.   DSR_Success = bguiwinopen(winID)
  2047.   if DSR_Success == 0 then bguierror(12)
  2048.  
  2049.   call CloseBusy(Req)
  2050.  
  2051.   /***//*** GUI Action Loop ***/
  2052.   Done  = 0
  2053.   Reset = 0
  2054.   do while 1
  2055.     call bguiwinwaitevent(winID,'ID')
  2056.     select
  2057.       when (id == id.cancel_) | (id == id.winclose) then Reset = 2
  2058.     /***//*** ResetGad ***/
  2059.       when id == id.reset_ then do
  2060.         Reset = 1
  2061.         PrefsFile = 'Default'
  2062.         call WriteFile('ENV:FWCalendar', PrefsFile, 'B')
  2063.       end
  2064.     /**/
  2065.  
  2066.     /***//*** LoadGad ***/
  2067.       when id == id.load_ then do
  2068.         CurrentPrefs = PrefsFile
  2069.         PrefsFile = bguifilereq(ScriptDir''"FWCalendar.prefs", SelectFile$':', winID,DOPATTERNS,'#?.(data|prefs)')
  2070.         if PrefsFile == '' then PrefsFile = CurrentPrefs
  2071.         else do
  2072.           if exists(PrefsFile) then do
  2073.             Reset = 1
  2074.             call WriteFile('ENV:FWCalendar', PrefsFile, 'B')
  2075.           end
  2076.           else do
  2077.             call bguireq(PrefsFile' 'CantFind$'...','*'OK$,'FWCalendar 'Notice$,winID)
  2078.             PrefsFile = CurrentPrefs
  2079.           end
  2080.         end
  2081.       end
  2082.     /**/
  2083.  
  2084.     /***//*** SaveAsGad ***/
  2085.       when id == id.saveas_ then do
  2086.         DSR_File = bguifilereq(ScriptDir'FWCalendar.prefs', SelectPrefs$)
  2087.         if DSR_File ~= '' then do
  2088.           PrefsFile = DSR_File
  2089.           call WriteFile('ENV:FWCalendar', PrefsFile, 'B')
  2090.         end
  2091.       end
  2092.     /**/
  2093.  
  2094.     /***//*** MiniCalsGad ***/
  2095.       when id == id.minicals_ then     DoMiniCals = sign(bguiget(obj.minicals_, GA_Selected))
  2096.     /**/
  2097.  
  2098.     /***//*** HighlightsGad ***/
  2099.       when id == id.highlights_ then   DoHighlights = sign(bguiget(obj.highlights_, GA_Selected))
  2100.     /**/
  2101.  
  2102.     /***//*** ExtendedGad ***/
  2103.       when id == id.extended_ then do
  2104.         DoExtended = sign(bguiget(obj.extended_, GA_Selected))
  2105.         if DoExtended == 1 then do
  2106.           call bguiset(obj.toplong_,winID, GA_Selected, 0, GA_Disabled, 1)
  2107.           DoTopExtraWk = sign(bguiget(obj.toplong_, GA_Selected))
  2108.           call bguiset(obj.notebox_,winID, GA_Selected, 0, GA_Disabled, 1)
  2109.           DoNoteBox = sign(bguiget(obj.notebox_, GA_Selected))
  2110.         end
  2111.         else do
  2112.           call bguiset(obj.toplong_,winID, GA_Disabled, 0)
  2113.           call bguiset(obj.notebox_,winID, GA_Disabled, 0)
  2114.         end
  2115.       end
  2116.     /**/
  2117.  
  2118.     /***//*** Checkbox & Margin Gads ***/
  2119.       when id == id.toplong_ then      DoTopExtraWk = sign(bguiget(obj.toplong_, GA_Selected))
  2120.       when id == id.notebox_ then      DoNoteBox = sign(bguiget(obj.notebox_, GA_Selected))
  2121.       when id == id.dateboxes_ then    DoDateBox = sign(bguiget(obj.dateboxes_, GA_Selected))
  2122.       when id == id.images_ then       DoImages = sign(bguiget(obj.images_, GA_Selected))
  2123.       when id == id.matchcolors_ then  DoMatchColors = sign(bguiget(obj.matchcolors_, GA_Selected))
  2124.       when id == id.dailycolors_ then  DoDailyColors = sign(bguiget(obj.dailycolors_, GA_Selected))
  2125.       when id == id.topmargin_ then    Margin.Top = bguiget(obj.topmargin_, STRINGA_TextVal)
  2126.       when id == id.leftmargin_ then   Margin.Left = bguiget(obj.leftmargin_, STRINGA_TextVal)
  2127.       when id == id.rightmargin_ then  Margin.Right = bguiget(obj.rightmargin_, STRINGA_TextVal)
  2128.       when id == id.bottommargin_ then Margin.Bottom = bguiget(obj.bottommargin_, STRINGA_TextVal)
  2129.       when id == id.orientation_ then do
  2130.         if bguiget(obj.orientation_,CYC_Active) == 0 then Orientation = 'Wide'
  2131.         else Orientation = 'Tall'
  2132.       end
  2133.     /**/
  2134.  
  2135.     /***//*** FontValueGad ***/
  2136.       when id == id.fontvalue_ then do
  2137.         call bguireq('1b'x||"c"MustUse$,"*"OK$,'',winID)
  2138.         call bguiset(obj.fontvalue_, winID,STRINGA_TextVal, value(CurrentFontName))
  2139.       end
  2140.     /**/
  2141.  
  2142.     /***//*** AddFontGad ***/
  2143.       when id == id.addfont_ then do
  2144.         if App == 'FW' then do
  2145.           FontFile = bguifilereq(CurrentDir'FWFonts/SWOLFonts/', SelectFont$':', winID,,'#?')
  2146.           if FontFile ~= '' then call bguiset(obj.fontvalue_, winID, STRINGA_TextVal,FontFile)
  2147.         end
  2148.         else if App == 'PGS' then do
  2149.           call bguiwinbusy(winID)
  2150.           call bguiwinopen(FontwinID)
  2151.           do while 1
  2152.             call bguiwinwaitevent(FontwinID,'ID')
  2153.             if id = id.winclose then leave
  2154.             if id = id.fontlistview_ then do
  2155.               call bguiset(obj.fontvalue_, winID, STRINGA_TextVal,bguiget(obj.fontlistview_, LISTV_LastClicked))
  2156.               leave
  2157.             end
  2158.           end
  2159.           call bguiwinclose(FontwinID)
  2160.           call bguiwinready(winID)
  2161.         end
  2162.       end
  2163.     /**/
  2164.  
  2165.     /***//*** FontVarGad ***/
  2166.       when id == id.fontvar_ then do
  2167.         interpret CurrentFontName" = "QuoteIt(bguiget(obj.fontvalue_, STRINGA_TextVal))
  2168.         CurrentFontName = value('FontVarName.'bguiget(obj.fontvar_, CYC_Active))
  2169.         call bguiset(obj.fontvalue_,winID,STRINGA_TextVal,Value(CurrentFontName))
  2170.       end
  2171.     /**/
  2172.  
  2173.     /***//*** AddVarGad ***/
  2174.       when id == id.addvar_ then do
  2175.         if (upper(CurrentMiscName) == 'GFXAPPPATH') | (upper(CurrentMiscName) == 'GFXAPP') then do
  2176.           Value = bguifilereq(GfxAppPath, SelectApp$':', winID,,'#?')
  2177.           if Value ~= '' then do
  2178.             GPath = pathpart(Value)
  2179.             GFile = filepart(Value)
  2180.             if upper(CurrentMiscName) == 'GFXAPPPATH' then call bguiset(obj.currentvalue_, winID, STRINGA_TextVal,GPath)
  2181.             else call bguiset(obj.currentvalue_, winID, STRINGA_TextVal,GFile)
  2182.             interpret 'GfxAppPath = 'QuoteIt(GPath)
  2183.             interpret 'GfxApp = 'QuoteIt(GFile)
  2184.             if (exists(GfxAppPath''GfxApp)) & (~exists(Storage''GfxApp)) then do
  2185.               address command 'copy 'GfxAppPath''GfxApp' 'Storage
  2186.               call bguiset(obj.images_,winID,GA_Disabled,~exists(Storage''GfxApp))
  2187.             end
  2188.           end
  2189.         end
  2190.  
  2191.         else if (upper(CurrentMiscName) == 'SUNCALCPATH') then do
  2192.           Value = bguifilereq(CurrentDir, SelectApp$':', winID,,'#?')
  2193.           if (Value ~= '') & (upper(right(Value, 7)) == 'SUNCALC') then do
  2194.             Value = pathpart(Value)
  2195.             call bguiset(obj.currentvalue_, winID, STRINGA_TextVal,Value)
  2196.             interpret 'SuncalcPath = 'QuoteIt(Value)
  2197.             if (exists(SuncalcPath'suncalc')) & (~exists(Storage'Suncalc')) then do
  2198.               address command 'copy 'SunCalcPath'suncalc 'Storage
  2199.               do i = 0 to GroupCount
  2200.                 interpret 'call bguiset('grp.i',winID,MX_EnableButton,6,MX_EnableButton,7,MX_EnableButton,8)'
  2201.               end
  2202.             end
  2203.           end
  2204.         end
  2205.  
  2206.         else if left(upper(CurrentMiscName), 11) == 'IMAGECLASS.' then do
  2207.           Value = bguifilereq(CurrentDir, SelectImage$':', winID,,'#?')
  2208.           if Value ~= '' then do
  2209.             call bguiset(obj.currentvalue_, winID, STRINGA_TextVal,Value)
  2210.             IC = MemberID(upper(substr(CurrentMiscName, 12)), 'ImageClass')
  2211.             interpret 'ImageFile.'IC' = Value'
  2212.           end
  2213.         end
  2214.       end
  2215.     /**/
  2216.  
  2217.     /***//*** ColorVarGad ***/
  2218.       when id == id.colorvar_ then do
  2219.         interpret CurrentColorName' = "'value('ColorList.'bguiget(obj.colorlist_, CYC_Active))'"'
  2220.         CurrentColorName = value('ColorVarName.'bguiget(obj.colorvar_, CYC_Active))
  2221.         call bguiset(obj.colorlist_,winID,CYC_Active,max(0, MemberID(Value(CurrentColorName),'ColorList')))
  2222.         CurrentColor = bguiget(obj.colorlist_, CYC_Active)
  2223.       end
  2224.     /**/
  2225.  
  2226.     /***//*** ColorListGad ***/
  2227.       when id == id.colorlist_ then do
  2228.         if (pos('BACKGROUND.', upper(CurrentColorName)) == 0) & (bguiget(obj.colorlist_, CYC_Active) == ColorList.Count - 1) then do
  2229.           call bguireq('1b'x||"c"NotClear$,"*"OK$,'',winID)
  2230.           call bguiset(obj.colorlist_, winID, CYC_Active, CurrentColor)
  2231.         end
  2232.       end
  2233.     /**/
  2234.  
  2235.     /***//*** CurrentVarGad ***/
  2236.       when id == id.currentvar_ then do
  2237.         Value = bguiget(obj.currentvalue_, STRINGA_TextVal)
  2238.         if upper(left(CurrentMiscName, pos('.', CurrentMiscName))) == 'IMAGECLASS.' then do
  2239.           IC = MemberID(upper(substr(CurrentMiscName, 12)), 'ImageClass')
  2240.           interpret 'ImageFile.'IC' = Value'
  2241.         end
  2242.         else do
  2243.           if datatype(Value) == 'CHAR' then Value = QuoteIt(Value)
  2244.           interpret CurrentMiscName' = 'Value
  2245.         end
  2246.         CurrentMiscName = value('MiscVarName.'bguiget(obj.currentvar_, CYC_Active))
  2247.         if upper(left(CurrentMiscName, pos('.', CurrentMiscName))) == 'IMAGECLASS.' then do
  2248.           IC = MemberID(upper(substr(CurrentMiscName, 12)), 'ImageClass')
  2249.           call bguiset(obj.currentvalue_,winID,STRINGA_TextVal,value('ImageFile.IC'))
  2250.         end
  2251.         else call bguiset(obj.currentvalue_,winID,STRINGA_TextVal,Value(CurrentMiscName))
  2252.         UCMN = upper(CurrentMiscName)
  2253.         if (UCMN == 'GFXAPPPATH') | (UCMN == 'SUNCALCPATH') | (UCMN == 'GFXAPP') | (left(UCMN, 11) == 'IMAGECLASS.') then VarReqGad = 1
  2254.         else VarReqGad = 0
  2255.         call bguiset(obj.addvar_, winID, GA_Disabled, ~VarReqGad)
  2256.       end
  2257.     /**/
  2258.  
  2259.     /***//*** CurrentValueGad ***/
  2260.       when id == id.currentvalue_ then do
  2261.         if (upper(CurrentMiscName) == 'GFXAPPPATH') | (upper(CurrentMiscName) == 'GFXAPP') | (upper(CurrentMiscName) == 'SUNCALCPATH') then do
  2262.           call bguireq('1b'x||"c"MustUse$,"*"OK$,'',winID)
  2263.           call bguiset(obj.currentvalue_, winID,STRINGA_TextVal, value(CurrentMiscName))
  2264.         end
  2265.         else if left(upper(CurrentMiscName), 11) == 'IMAGECLASS.' then do
  2266.           if bguiget(obj.currentvalue_, STRINGA_TextVal) ~= '' then do
  2267.             call bguireq('1b'x||"c"MustUse$,"*"OK$,'',winID)
  2268.             IC = MemberID(upper(substr(CurrentMiscName, 12)), 'ImageClass')
  2269.             call bguiset(obj.currentvalue_, winID,STRINGA_TextVal, ImageFile.IC)
  2270.           end
  2271.         end
  2272.       end
  2273.     /**/
  2274.  
  2275.     /***//*** SetHighlightsGad ***/
  2276.       when id == id.sethighlights_ then do
  2277.         EH_SelectMonth = bguiget(obj.monthchoice_, CYC_Active) + 1
  2278.         call bguiwinbusy(winID)
  2279.         do until DS_Done == 1
  2280.           DS_Done = EditHighlight_BGUI()
  2281.         end
  2282.         call bguiwinready(winID)
  2283.       end
  2284.     /**/
  2285.  
  2286.     /***//*** CalendarTypeGad ***/
  2287.     when id == id.calendartype_ then do
  2288.       CalType = bguiget(obj.calendartype_, CYC_Active) + 1
  2289.       if (App == 'FW') & (CalType == 2) then CalType = 3
  2290.       if CalType == 1 then do
  2291.         call bguiset(obj.monthchoice_, winID, GA_Disabled, 0)
  2292.         if App == 'PGS' then call bguiset(obj.endmonthchoice_, winID, GA_Disabled, 1)
  2293.       end
  2294.       else if CalType == 2 then do
  2295.         call bguiset(obj.monthchoice_, winID, GA_Disabled, 0)
  2296.         call bguiset(obj.endmonthchoice_, winID, GA_Disabled, 0)
  2297.       end
  2298.       else do
  2299.         call bguiset(obj.monthchoice_, winID, GA_Disabled, 1)
  2300.         if App == 'PGS' then call bguiset(obj.endmonthchoice_, winID, GA_Disabled, 1)
  2301.       end
  2302.     end
  2303.     /**/
  2304.  
  2305.     /***//*** GoGad ***/
  2306.     when id == id.go_ then do
  2307.       CalType = bguiget(obj.calendartype_, CYC_Active) + 1
  2308.       if (App == 'FW') & (CalType == 2) then CalType = 3
  2309.       EnteredYear = bguiget(obj.yearchoice_, STRINGA_TextVal)
  2310.       Month = bguiget(obj.monthchoice_, CYC_Active) + 1
  2311.       if CalType == 2 then EndMonth = bguiget(obj.endmonthchoice_, CYC_Active) + 1
  2312.       Done = 1
  2313.     end
  2314.     /**/
  2315.  
  2316.     /***//*** Extras Gads ***/
  2317.       when id == id.bottomleft_ then   call ControlMX(0, bguiget(obj.bottomleft_, MX_Active))
  2318.       when id == id.bottomcenter_ then call ControlMX(1, bguiget(obj.bottomcenter_, MX_Active))
  2319.       when id == id.bottomright_ then  call ControlMX(2, bguiget(obj.bottomright_, MX_Active))
  2320.       when id == id.topcenter_ then    call ControlMX(3, bguiget(obj.topcenter_, MX_Active))
  2321.       when id == id.topright_ then     call ControlMX(4, bguiget(obj.topright_, MX_Active))
  2322.     /**/
  2323.       otherwise nop
  2324.     end
  2325.     if (Done == 1) | (Reset > 0) then leave
  2326.   end
  2327. /**/
  2328.  
  2329.   do DSR_Posn = 0 to PosnCount
  2330.     interpret "Do"Do.DSR_Posn" = ''"
  2331.   end
  2332.   do DSR_Grp = 0 to GroupCount
  2333.     DSR_Posn = DSR_Sel.DSR_Grp
  2334.     interpret "Do"Do.DSR_Posn" = translate(DSR_Grp, 'BBBTT', '01234')||translate(DSR_Grp, 'LCRCR', '01234')"
  2335.   end
  2336.  
  2337.   if DoBothJ ~= '' then do
  2338.     DoJulian = DoBothJ
  2339.     DoJulianLeft = DoBothJ
  2340.   end
  2341.   if DoBothS ~= '' then do
  2342.     DoSunrise = DoBothS
  2343.     DoSunset = DoBothS
  2344.   end
  2345.   TopOption = sign(pos('T', DoPhases''DoWeeknumber''DoJulian''DoJulianLeft''DoSunrise''DoSunset))
  2346.  
  2347.   if CalType ~= 0 then do
  2348.     interpret CurrentFontName" = "QuoteIt(bguiget(obj.fontvalue_, STRINGA_TextVal))
  2349.     interpret CurrentColorName' = "'value('ColorList.'bguiget(obj.colorlist_, CYC_Active))'"'
  2350.  
  2351.     Value = bguiget(obj.currentvalue_, STRINGA_TextVal)
  2352.     if upper(left(CurrentMiscName, pos('.', CurrentMiscName))) == 'IMAGECLASS.' then do
  2353.       IC = MemberID(upper(substr(CurrentMiscName, 12)), 'ImageClass')
  2354.       interpret 'ImageFile.'IC' = Value'
  2355.     end
  2356.     else do
  2357.       if datatype(Value) == 'CHAR' then  Value = QuoteIt(Value)
  2358.       interpret CurrentMiscName' = 'Value
  2359.     end
  2360.   end
  2361.  
  2362.   return
  2363. /**/
  2364.  
  2365. /***//*** DoSetupReq_CA () ***/
  2366. DoSetupReq_CA:
  2367.   /***//*** GUI Description ***/
  2368.   UpdateVarCmds = 0
  2369.   NCColorReq = 0
  2370.   ColorReq = 0
  2371.   MonthList = '"'January$'|'February$'|'March$'|'April$'|'May$'|'June$'|'July$'|'August$'|'September$'|'October$'|'November$'|'December$'"'
  2372.   if App == 'FW' then CalendarTypeList = '"'SingleMonth$'|'WholeYear$'"'
  2373.   else CalendarTypeList = '"'SingleMonth$'|'MultiMonth$'|'WholeYear$'"'
  2374.  
  2375.   call open('CA',"awnpipe:SetupReq/xc")
  2376.   call ToPIPE('CA', '"'VarGUITitle$'" m cg dg v db si a cs sk sq h ps="'AppScreen'"')
  2377.   call ToPIPE('CA', 'layout v si so cj')
  2378.     DisplayNameGad = ToPIPE('CA', 'button ro b=0')
  2379.     call AssignID('ClickTab', ToPIPE('CA', 'clicktab ctl="'OptLayout$'|'Variables$'|'Top$'|'Bottom$'"'))
  2380.  
  2381.     /***//** Options & Layout Tab **/
  2382.     call ToPIPE('CA', 'layout v si so b=0 page='ClickTab)
  2383.       call ToPIPE('CA', 'layout b=3 gt="'Options$'"')
  2384.         call ToPIPE('CA', 'layout v si so b=0')
  2385.           call AssignID('MiniCalsGad', ToPIPE('CA', 'checkbox gt="'MiniCals$'"'))
  2386.           call AssignID('HighlightsGad', ToPIPE('CA', 'checkbox gt="'Highlights$'"'))
  2387.           call AssignID('ImagesGad', ToPIPE('CA', 'checkbox gt="'Images$'"'))
  2388.           call AssignID('BoxDatesGad', ToPIPE('CA', 'checkbox gt="'BoxDates$'"'))
  2389.         call ToPIPE('CA', 'le')
  2390.         call ToPIPE('CA', 'layout v si so b=0')
  2391.           call AssignID('ExtendedGad', ToPIPE('CA', 'checkbox gt="'Extended$'"'))
  2392.           call AssignID('TopLongGad', ToPIPE('CA', 'checkbox gt="'TopLong$'"'))
  2393.           call AssignID('NoteBoxGad', ToPIPE('CA', 'checkbox gt="'NoteBox$'"'))
  2394.           call ToPIPE('CA', 'space')
  2395.         call ToPIPE('CA', 'le')
  2396.       call ToPIPE('CA', 'le')
  2397.  
  2398.       call ToPIPE('CA', 'layout v si so cj b=3 gt="'OrientMarg$'"')
  2399.         call ToPIPE('CA', 'layout b=0')
  2400.           call ToPIPE('CA', 'space')
  2401.           call AssignID('TopMargGad', ToPIPE('CA', 'string cj tc weiw=20'))
  2402.           call ToPIPE('CA', 'space')
  2403.         call ToPIPE('CA', 'le')
  2404.         call ToPIPE('CA', 'layout si b=0')
  2405.           call ToPIPE('CA', 'space')
  2406.           call AssignID('LeftMargGad', ToPIPE('CA', 'string cj tc weiw=20'))
  2407.           call AssignID('OrientationGad', ToPIPE('CA', 'chooser pu weiw=20 cl="'Wide$'|'Tall$'"'))
  2408.           call AssignID('RightMargGad', ToPIPE('CA', 'string cj tc weiw=20'))
  2409.           call ToPIPE('CA', 'space')
  2410.         call ToPIPE('CA', 'le')
  2411.         call ToPIPE('CA', 'layout b=0')
  2412.           call ToPIPE('CA', 'space')
  2413.           call AssignID('BottomMargGad', ToPIPE('CA', 'string cj tc weiw=20'))
  2414.           call ToPIPE('CA', 'space')
  2415.         call ToPIPE('CA', 'le')
  2416.       call ToPIPE('CA', 'le')
  2417.     call ToPIPE('CA', 'le')
  2418.     if UpdateBusy(Req, 1) == -1 then call Cleanup
  2419.     /**/
  2420.  
  2421.     /***//** Variables Tab **/
  2422.     call ToPIPE('CA', 'layout v si so b=0 page='ClickTab)
  2423.       call ToPIPE('CA', 'layout so b=3 gt="'Fonts$'"')
  2424.         call AssignID('FontVarGad', ToPIPE('CA', 'chooser pu maxn=50 weiw=45'))
  2425.         call AssignID('FontValGad', ToPIPE('CA', 'string lj tc weiw=50'))
  2426.         call AssignID('ChooseFontGad', ToPIPE('CA', 'button ab=2 weiw=0 weih=0'))
  2427.       call ToPIPE('CA', 'le')
  2428.  
  2429.       call ToPIPE('CA', 'layout v b=3 gt="'Colors$'" si so')
  2430.         call ToPIPE('CA', 'layout b=0')
  2431.           call AssignID('ColorVarGad', ToPIPE('CA', 'button weiw=50 weih=0'))
  2432.           call AssignID('CycleColorVarGad', ToPIPE('CA', 'button weiw=0 gt=">"'))
  2433.           call AssignID('ColorValGad', ToPIPE('CA', 'button weiw=45 weih=0'))
  2434.         call ToPIPE('CA', 'le')
  2435.         call AssignID('MatchColorsGad', ToPIPE('CA', 'checkbox gt="'MatchColors$'"'))
  2436.         call AssignID('DailyColorsGad', ToPIPE('CA', 'checkbox gt="'DailyColors$'"'))
  2437.       call ToPIPE('CA', 'le')
  2438.  
  2439.       call ToPIPE('CA', 'layout v b=3 gt="'MiscVar$'" si so')
  2440.         call ToPIPE('CA', 'layout b=0')
  2441.           call ToPIPE('CA', 'space')
  2442.           call AssignID('HighlightEditGad', ToPIPE('CA', 'button gt="'HighlightEd$'"'))
  2443.           call ToPIPE('CA', 'space')
  2444.         call ToPIPE('CA', 'le')
  2445.         call ToPIPE('CA', 'layout b=0')
  2446.           call AssignID('MiscVarGad', ToPIPE('CA', 'button weiw=50'))
  2447.           call AssignID('CycleMiscVarGad', ToPIPE('CA', 'button weiw=0 gt=">"'))
  2448.           call AssignID('MiscValGad', ToPIPE('CA', 'string lj tc weiw=40 weih=0'))
  2449.           call AssignID('ChooseValGad', ToPIPE('CA', 'button ab=0 weiw=0 weih=0'))
  2450.           call AssignID('AddImageClassGad', ToPIPE('CA', 'button weiw=0 gt="'AddIC$'"'))
  2451.         call ToPIPE('CA', 'le')
  2452.       call ToPIPE('CA', 'le')
  2453.     call ToPIPE('CA', 'le')
  2454.  
  2455.     GadText.CycleColorVarGad.0 = '>'
  2456.     GadText.CycleColorVarGad.1 = '<'
  2457.     GadText.CycleMiscVarGad.0 = '>'
  2458.     GadText.CycleMiscVarGad.1 = '<'
  2459.     if UpdateBusy(Req, 1) == -1 then call Cleanup
  2460.     /**/
  2461.  
  2462.     /***//** Top Options Tab **/
  2463.     call ToPIPE('CA', 'layout b=0 page='ClickTab)
  2464.       call ToPIPE('CA', 'space')
  2465.  
  2466.       call ToPIPE('CA', 'layout v cj b=3')
  2467.         call ToPIPE('CA', 'label gt="'Top$'*n'Center$'"')
  2468.         call ToPIPE('CA', 'layout v so b=0')
  2469.           call AssignID('Gad.3.0', ToPIPE('CA', 'checkbox gt="'None$'"'))
  2470.           call AssignID('Gad.3.1', ToPIPE('CA', 'checkbox gt="'Phases$'"'))
  2471.           call AssignID('Gad.3.2', ToPIPE('CA', 'checkbox gt="'Weeknumber$'"'))
  2472.           call AssignID('Gad.3.3', ToPIPE('CA', 'checkbox gt="'Julian$'"'))
  2473.           call AssignID('Gad.3.4', ToPIPE('CA', 'checkbox gt="'JulLeft$'"'))
  2474.           call AssignID('Gad.3.5', ToPIPE('CA', 'checkbox gt="'JulJulLeft$'"'))
  2475.           call AssignID('Gad.3.6', ToPIPE('CA', 'checkbox gt="'Sunrise$'"'))
  2476.           call AssignID('Gad.3.7', ToPIPE('CA', 'checkbox gt="'Sunset$'"'))
  2477.           call AssignID('Gad.3.8', ToPIPE('CA', 'checkbox gt="'RiseSet$'"'))
  2478.           call ToPIPE('CA', 'space')
  2479.         call ToPIPE('CA', 'le')
  2480.       call ToPIPE('CA', 'le')
  2481.  
  2482.       call ToPIPE('CA', 'layout v cj b=3')
  2483.         call ToPIPE('CA', 'label gt="'Top$'*n'Right$'"')
  2484.         call ToPIPE('CA', 'layout v so b=0')
  2485.           call AssignID('Gad.4.0', ToPIPE('CA', 'checkbox gt="'None$'"'))
  2486.           call AssignID('Gad.4.1', ToPIPE('CA', 'checkbox gt="'Phases$'"'))
  2487.           call AssignID('Gad.4.2', ToPIPE('CA', 'checkbox gt="'Weeknumber$'"'))
  2488.           call AssignID('Gad.4.3', ToPIPE('CA', 'checkbox gt="'Julian$'"'))
  2489.           call AssignID('Gad.4.4', ToPIPE('CA', 'checkbox gt="'JulLeft$'"'))
  2490.           call AssignID('Gad.4.5', ToPIPE('CA', 'checkbox gt="'JulJulLeft$'"'))
  2491.           call AssignID('Gad.4.6', ToPIPE('CA', 'checkbox gt="'Sunrise$'"'))
  2492.           call AssignID('Gad.4.7', ToPIPE('CA', 'checkbox gt="'Sunset$'"'))
  2493.           call AssignID('Gad.4.8', ToPIPE('CA', 'checkbox gt="'RiseSet$'"'))
  2494.           call ToPIPE('CA', 'space')
  2495.         call ToPIPE('CA', 'le')
  2496.       call ToPIPE('CA', 'le')
  2497.     call ToPIPE('CA', 'le')
  2498.     if UpdateBusy(Req, 1) == -1 then call Cleanup
  2499.     /**/
  2500.  
  2501.     /***//** Bottom Options Tab **/
  2502.     call ToPIPE('CA', 'layout b=0 page='ClickTab)
  2503.       call ToPIPE('CA', 'layout v cj b=3')
  2504.         call ToPIPE('CA', 'label gt="'Bottom$'*n'Left$'"')
  2505.         call ToPIPE('CA', 'layout v so b=0')
  2506.           call AssignID('Gad.0.0', ToPIPE('CA', 'checkbox gt="'None$'"'))
  2507.           call AssignID('Gad.0.1', ToPIPE('CA', 'checkbox gt="'Phases$'"'))
  2508.           call AssignID('Gad.0.2', ToPIPE('CA', 'checkbox gt="'Weeknumber$'"'))
  2509.           call AssignID('Gad.0.3', ToPIPE('CA', 'checkbox gt="'Julian$'"'))
  2510.           call AssignID('Gad.0.4', ToPIPE('CA', 'checkbox gt="'JulLeft$'"'))
  2511.           call AssignID('Gad.0.5', ToPIPE('CA', 'checkbox gt="'JulJulLeft$'"'))
  2512.           call AssignID('Gad.0.6', ToPIPE('CA', 'checkbox gt="'Sunrise$'"'))
  2513.           call AssignID('Gad.0.7', ToPIPE('CA', 'checkbox gt="'Sunset$'"'))
  2514.           call AssignID('Gad.0.8', ToPIPE('CA', 'checkbox gt="'RiseSet$'"'))
  2515.           call ToPIPE('CA', 'space')
  2516.         call ToPIPE('CA', 'le')
  2517.       call ToPIPE('CA', 'le')
  2518.  
  2519.       call ToPIPE('CA', 'layout v cj b=3')
  2520.         call ToPIPE('CA', 'label gt="'Bottom$'*n'Center$'"')
  2521.         call ToPIPE('CA', 'layout v so b=0')
  2522.           call AssignID('Gad.1.0', ToPIPE('CA', 'checkbox gt="'None$'"'))
  2523.           call AssignID('Gad.1.1', ToPIPE('CA', 'checkbox gt="'Phases$'"'))
  2524.           call AssignID('Gad.1.2', ToPIPE('CA', 'checkbox gt="'Weeknumber$'"'))
  2525.           call AssignID('Gad.1.3', ToPIPE('CA', 'checkbox gt="'Julian$'"'))
  2526.           call AssignID('Gad.1.4', ToPIPE('CA', 'checkbox gt="'JulLeft$'"'))
  2527.           call AssignID('Gad.1.5', ToPIPE('CA', 'checkbox gt="'JulJulLeft$'"'))
  2528.           call AssignID('Gad.1.6', ToPIPE('CA', 'checkbox gt="'Sunrise$'"'))
  2529.           call AssignID('Gad.1.7', ToPIPE('CA', 'checkbox gt="'Sunset$'"'))
  2530.           call AssignID('Gad.1.8', ToPIPE('CA', 'checkbox gt="'RiseSet$'"'))
  2531.           call AssignID('Gad.1.9', ToPIPE('CA', 'checkbox gt="'History$'"'))
  2532.           call AssignID('Gad.1.10', ToPIPE('CA', 'checkbox gt="'Random$'"'))
  2533.           call ToPIPE('CA', 'space')
  2534.         call ToPIPE('CA', 'le')
  2535.       call ToPIPE('CA', 'le')
  2536.  
  2537.       call ToPIPE('CA', 'layout v cj b=3')
  2538.         call ToPIPE('CA', 'label gt="'Bottom$'*n'Right$'"')
  2539.         call ToPIPE('CA', 'layout v so b=0')
  2540.           call AssignID('Gad.2.0', ToPIPE('CA', 'checkbox gt="'None$'"'))
  2541.           call AssignID('Gad.2.1', ToPIPE('CA', 'checkbox gt="'Phases$'"'))
  2542.           call AssignID('Gad.2.2', ToPIPE('CA', 'checkbox gt="'Weeknumber$'"'))
  2543.           call AssignID('Gad.2.3', ToPIPE('CA', 'checkbox gt="'Julian$'"'))
  2544.           call AssignID('Gad.2.4', ToPIPE('CA', 'checkbox gt="'JulLeft$'"'))
  2545.           call AssignID('Gad.2.5', ToPIPE('CA', 'checkbox gt="'JulJulLeft$'"'))
  2546.           call AssignID('Gad.2.6', ToPIPE('CA', 'checkbox gt="'Sunrise$'"'))
  2547.           call AssignID('Gad.2.7', ToPIPE('CA', 'checkbox gt="'Sunset$'"'))
  2548.           call AssignID('Gad.2.8', ToPIPE('CA', 'checkbox gt="'RiseSet$'"'))
  2549.           call ToPIPE('CA', 'space')
  2550.         call ToPIPE('CA', 'le')
  2551.       call ToPIPE('CA', 'le')
  2552.     call ToPIPE('CA', 'le')
  2553.     if UpdateBusy(Req, 1) == -1 then call Cleanup
  2554.     /**/
  2555.  
  2556.     /***//** Control Buttons **/
  2557.     call ToPIPE('CA', 'layout si so b=0')
  2558.       call ToPIPE('CA', 'space')
  2559.       call AssignID('SwitchGad1', ToPIPE('CA', 'chooser pu cl='MonthList))
  2560.       call AssignID('SwitchGad2', ToPIPE('CA', 'integer a tc weiw=5 maxc=4'))
  2561.       call AssignID('SwitchGad3', ToPIPE('CA', 'button b=0 weiw=30 weih=0 gt=""'))
  2562.       call ToPIPE('CA', 'space')
  2563.     call ToPIPE('CA', 'le')
  2564.  
  2565.     call ToPIPE('CA', 'layout cj si so b=0')
  2566.       call AssignID('CalendarTypeGad', ToPIPE('CA', 'chooser pu weiw=0 weih=0 cl='CalendarTypeList))
  2567.       call AssignID('GoGad', ToPIPE('CA', 'button weih=0 gt="'Go$'"'))
  2568.       call ToPIPE('CA', 'space')
  2569.       call AssignID('ResetGad', ToPIPE('CA', 'button weih=0 gt="'Reset$'"'))
  2570.       call AssignID('LoadGad', ToPIPE('CA', 'button weih=0 gt="'Load$'"'))
  2571.       call AssignID('SaveAsGad', ToPIPE('CA', 'button weih=0 gt="'SaveAs$'"'))
  2572.       call ToPIPE('CA', 'space')
  2573.       call AssignID('CancelGad', ToPIPE('CA', 'button weih=0 gt="'Cancel$'" c'))
  2574.     call ToPIPE('CA', 'le')
  2575.     if UpdateBusy(Req, 1) == -1 then call Cleanup
  2576.     /**/
  2577.  
  2578.     /***//*** Other Objects ***/
  2579.     GetFileAllGad = ToPIPE('CA', 'getfile ua pat="#?"')
  2580.     GetFileDataGad = ToPIPE('CA', 'getfile ua pat="#?.(data|prefs)"')
  2581.  
  2582.     if App == 'PGS' then do
  2583.       call open('FontReq', "awnpipe:FontReq/xc")
  2584.       call ToPIPE('FontReq', '"'SelectFont$'" m db dg v db a ps="'AppScreen'"')
  2585.       call ToPIPE('FontReq', 'listbrowser minw=200 minh=300')
  2586.       do DSR_FontNumber = 0 to FontList.COUNT - 1
  2587.         GadID = ToPIPE('FontReq', 'browsernode gt="'FontList.DSR_FontNumber'"')
  2588.         interpret 'FontGad.'GadID' = 'DSR_FontNumber
  2589.       end
  2590.     end
  2591.  
  2592.     call open('ColorReq','awnpipe:ColorReq/xc')
  2593.     call ToPIPE('ColorReq','"Select color:" m db dg v a ps="'AppScreen'"')
  2594.     call ToPIPE('ColorReq','listbrowser minw 150 minh 75 lbl "Color|Sample"')
  2595.  
  2596.     call open('NCColorReq','awnpipe:NCColorReq/xc')
  2597.     call ToPIPE('NCColorReq','"Select color:" m db dg v a ps="'AppScreen'"')
  2598.     call ToPIPE('NCColorReq','listbrowser minw 150 minh 75 lbl "Color|Sample"')
  2599.     if App == 'FW' then do
  2600.       do GE_ColorNumber = 0 to ColorList.Count - 2
  2601.         if UpdateBusy(Req, 1) == -1 then call Cleanup
  2602.         RPen = dTox(x2d(left(ColorRegister.GE_ColorNumber, 2)) / 255 * 4294967295)
  2603.         GPen = dTox(x2d(substr(ColorRegister.GE_ColorNumber, 3, 2)) / 255 * 4294967295)
  2604.         BPen = dTox(x2d(right(ColorRegister.GE_ColorNumber, 2)) / 255 * 4294967295)
  2605.  
  2606.         call ToPIPE('ColorReq','penmap pmp 1|'RPen'|'GPen'|'BPen' pmd 0|'d2x(ColorW)'|0|'d2x(ColorH)''copies('|0', ColorW * ColorH))
  2607.         GadID = ToPIPE('ColorReq','browsernode gt="'ColorList.GE_ColorNumber'|¶"')
  2608.         interpret 'ColorGad.'GadID' = 'GE_ColorNumber
  2609.  
  2610.         call ToPIPE('NCColorReq','penmap pmp 1|'RPen'|'GPen'|'BPen' pmd 0|'d2x(ColorW)'|0|'d2x(ColorH)''copies('|0', ColorW * ColorH))
  2611.         GadID = ToPIPE('NCColorReq','browsernode gt="'ColorList.GE_ColorNumber'|¶"')
  2612.         interpret 'NCColorGad.'GadID' = 'GE_ColorNumber
  2613.       end
  2614.       GadID = ToPIPE('ColorReq','browsernode gt="<'Clear$'>|¶"')
  2615.       interpret 'ColorGad.'GadID' = 'GE_ColorNumber
  2616.     end
  2617.     else if App == 'PGS' then do
  2618.       do GE_ColorNumber = 0 to ColorList.Count - 2
  2619.         if UpdateBusy(Req, 1) == -1 then call Cleanup
  2620.         GadID = ToPIPE('ColorReq','browsernode gt="'ColorList.GE_ColorNumber'|"')
  2621.         interpret 'ColorGad.'GadID' = 'GE_ColorNumber
  2622.         GadID = ToPIPE('NCColorReq','browsernode gt="'ColorList.GE_ColorNumber'|"')
  2623.         interpret 'NCColorGad.'GadID' = 'GE_ColorNumber
  2624.       end
  2625.       GadID = ToPIPE('ColorReq','browsernode gt="<'Clear$'>|"')
  2626.       interpret 'ColorGad.'GadID' = 'GE_ColorNumber
  2627.     end
  2628.     /**/
  2629.  
  2630.   call ToPIPE('CA', 'le')
  2631.   call ToPIPE('CA', "open")
  2632.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  2633. /**/
  2634.  
  2635.   /***//*** GUI Action Loop ***/
  2636.   call CA_UpdateGads
  2637.   Done = 0
  2638.   do until Done == 1
  2639.     call ToPIPE('CA', 'continue')
  2640.     DSR_EventInfo = readln('CA')
  2641.     parse var DSR_EventInfo DSR_Event' 'DSR_GadID' 'DSR_GadInfo1
  2642.     select
  2643.       when DSR_Event == 'close' then call Cleanup
  2644.  
  2645.     /***//*** Help event ***/
  2646.       when DSR_Event == 'help' then do
  2647.         if DSR_GadID ~= -1 then do
  2648.           OverGad = DSR_GadID
  2649.           if (DSR_GadID ~= ShiftedGad) & (ShiftedGad > 0) then do
  2650.             call ToPIPE('CA', 'id 'ShiftedGad' gt="'GadText.ShiftedGad.0'"')
  2651.             ShiftedGad = 0
  2652.           end
  2653.           if (ShiftDown == 1) & (symbol('GadText.OverGad.1') == 'VAR') then do
  2654.             call ToPIPE('CA', 'id 'OverGad' gt="'GadText.OverGad.1'"')
  2655.             ShiftedGad = OverGad
  2656.           end
  2657.         end
  2658.       end
  2659.     /**/
  2660.  
  2661.     /***//*** Qualifier event ***/
  2662.       when DSR_Event == 'qual' then do
  2663.         ShiftDown = (DSR_GadID == 1)|(DSR_GadID == 2)
  2664.         if (ShiftDown == 0) & (ShiftedGad > 0) then do
  2665.           call ToPIPE('CA', 'id 'ShiftedGad' gt="'GadText.OverGad.0'"')
  2666.           ShiftedGad = 0
  2667.         end
  2668.         if (ShiftDown == 1) & (symbol('GadText.OverGad.1') == 'VAR') then do
  2669.           call ToPIPE('CA', 'id 'OverGad' gt="'GadText.OverGad.1'"')
  2670.           ShiftedGad = OverGad
  2671.         end
  2672.       end
  2673.     /**/
  2674.  
  2675.     /***//*** Key event ***/
  2676.       when DSR_Event == 'key' then do
  2677.         HelpGad = DSR_Help.OverGad
  2678.         interpret 'HelpText = Help$.'HelpGad
  2679.         if (DSR_GadID == 95) & (symbol('Help$.'HelpGad) == 'VAR') & (HelpText ~= '') then
  2680.           call CASimpleReq(Help$, HelpText, HelpTime)
  2681.       end
  2682.     /**/
  2683.  
  2684.     /***//*** CalendarTypeGad ***/
  2685.       when DSR_GadID == CalendarTypeGad then do
  2686.         call ReadMonthYearGads
  2687.         CalType = DSR_GadInfo1 + 1
  2688.         if (App == 'FW') & (CalType == 2) then CalType = 3
  2689.         if CalType == 1 then do
  2690.           call AssignID('SwitchGad1', ToPIPE('CA', 'define chooser replace='SwitchGad1' pu cl='MonthList' s='Month - 1))
  2691.           call AssignID('SwitchGad2', ToPIPE('CA', 'define integer replace='SwitchGad2' a tc weiw=5 maxc=4 defn='EnteredYear))
  2692.           call AssignID('SwitchGad3', ToPIPE('CA', 'define button replace='SwitchGad3' b=0 gt=""'))
  2693.           call ToPIPE('CA', 'refresh')
  2694.           Help$.SwitchGad1Help = Help$.MonthGadHelp
  2695.           Help$.SwitchGad2Help = Help$.YearGadHelp
  2696.           Help$.SwitchGad3Help = ''
  2697.         end
  2698.         else if CalType == 2 then do
  2699.           call AssignID('SwitchGad1', ToPIPE('CA', 'define chooser replace='SwitchGad1' pu cl='MonthList' s='Month - 1))
  2700.           call AssignID('SwitchGad2', ToPIPE('CA', 'define chooser replace='SwitchGad2' pu cl='MonthList' s='EndMonth - 1))
  2701.           call AssignID('SwitchGad3', ToPIPE('CA', 'define integer replace='SwitchGad3' a tc weiw=5 maxc=4 defn='EnteredYear))
  2702.           call ToPIPE('CA', 'refresh')
  2703.           Help$.SwitchGad1Help = Help$.StartMonthGadHelp
  2704.           Help$.SwitchGad2Help = Help$.EndMonthGadHelp
  2705.           Help$.SwitchGad3Help = Help$.YearGadHelp
  2706.         end
  2707.         else do
  2708.           call AssignID('SwitchGad1', ToPIPE('CA', 'define button replace='SwitchGad1' b=0 gt=""'))
  2709.           call AssignID('SwitchGad2', ToPIPE('CA', 'define integer replace='SwitchGad2' a tc weiw=5 maxc=4 defn='EnteredYear))
  2710.           call AssignID('SwitchGad3', ToPIPE('CA', 'define button replace='SwitchGad3' b=0 gt=""'))
  2711.           call ToPIPE('CA', 'refresh')
  2712.           Help$.SwitchGad1Help = ''
  2713.           Help$.SwitchGad2Help = Help$.YearGadHelp
  2714.           Help$.SwitchGad3Help = ''
  2715.         end
  2716.       end
  2717.     /**/
  2718.  
  2719.     /***//*** GoGad ***/
  2720.       when DSR_GadID == GoGad then do
  2721.         CalType = ReadCAGad('CA', CalendarTypeGad) + 1
  2722.         if (App == 'FW') & (CalType == 2) then CalType = 3
  2723.         call ReadMonthYearGads
  2724.         call CA_InterpretMX
  2725.         Done = 1
  2726.       end
  2727.     /**/
  2728.  
  2729.     /***//*** ResetGad ***/
  2730.       when DSR_GadID == ResetGad then do
  2731.         PrefsFile = 'Default'
  2732.         call WriteFile('ENV:FWCalendar', PrefsFile, 'B')
  2733.         call CA_UpdateGads
  2734.       end
  2735.     /**/
  2736.  
  2737.     /***//*** LoadGad ***/
  2738.       when DSR_GadID == LoadGad then do
  2739.         if PrefsFile ~= 'Default' then do
  2740.           DefaultSource = PathPart(PrefsFile)
  2741.           DefaultFile = FilePart(PrefsFile)
  2742.         end
  2743.         else do
  2744.           DefaultSource = ScriptDir
  2745.           DefaultFile = 'FWCalendar.prefs'
  2746.         end
  2747.         DSR_File = CAGetFile('CA', GetFileDataGad, SelectFile$, DefaultSource''DefaultFile)
  2748.         if (DSR_File ~= '') & (exists(DSR_File)) then do
  2749.           PrefsFile = DSR_File
  2750.           call WriteFile('ENV:FWCalendar', PrefsFile, 'B')
  2751.           GSI_Data = ReadFile(PrefsFile)
  2752.           GSI_UpperData = upper(GSI_Data)
  2753.           call CA_UpdateGads
  2754.         end
  2755.         else do
  2756.           call ToPIPE('CA', 'id 0 s=256')
  2757.           call CASimpleReq('FWCalendar 'Notice$, PrefsFile' 'CantFind$'...')
  2758.           call ToPIPE('CA', 'id 0 s=512')
  2759.         end
  2760.       end
  2761.     /**/
  2762.  
  2763.     /***//*** SaveAsGad ***/
  2764.       when DSR_GadID == SaveAsGad then do
  2765.         if PrefsFile ~= 'Default' then do
  2766.           DefaultSource = PathPart(PrefsFile)
  2767.           DefaultFile = FilePart(PrefsFile)
  2768.         end
  2769.         else do
  2770.           DefaultSource = ScriptDir
  2771.           DefaultFile = 'FWCalendar.prefs'
  2772.         end
  2773.         DSR_File = CAGetFile('CA', GetFileDataGad, SelectPrefs$, DefaultSource''DefaultFile)
  2774.         if DSR_File ~= '' then do
  2775.           PrefsFile = DSR_File
  2776.           call WriteFile('ENV:FWCalendar', PrefsFile, 'B')
  2777.         end
  2778.       end
  2779.     /**/
  2780.  
  2781.     /***//*** ExtendedGad ***/
  2782.       when DSR_GadID == ExtendedGad then do
  2783.         DoExtended = DSR_GadInfo1
  2784.         if DoExtended == 1 then do
  2785.           call ToPIPE('CA', 'id 'TopLongGad' s=0 dis=1 page='ClickTab' refresh')
  2786.           call ToPIPE('CA', 'id 'NoteBoxGad' s=0 dis=1 page='ClickTab' refresh')
  2787.           DoTopExtraWk = 0
  2788.           DoNoteBox = 0
  2789.         end
  2790.         else do
  2791.           call ToPIPE('CA', 'id 'TopLongGad' dis=0 page='ClickTab' refresh')
  2792.           call ToPIPE('CA', 'id 'NoteBoxGad' dis=0 page='ClickTab' refresh')
  2793.         end
  2794.       end
  2795.     /**/
  2796.  
  2797.     /***//*** OrientationGad ***/
  2798.       when DSR_GadID == OrientationGad then  do
  2799.         if DSR_GadInfo1 == 0 then Orientation = 'Wide'
  2800.         else Orientation = 'Tall'
  2801.       end
  2802.     /**/
  2803.  
  2804.     /***//*** Checkbox Gads ***/
  2805.       when DSR_GadID == MinicalsGad then     DoMiniCals = DSR_GadInfo1
  2806.       when DSR_GadID == HighlightsGad then   DoHighlights = DSR_GadInfo1
  2807.       when DSR_GadID == TopLongGad then      DoTopExtraWk = DSR_GadInfo1
  2808.       when DSR_GadID == NoteBoxGad then      DoNoteBox = DSR_GadInfo1
  2809.       when DSR_GadID == BoxDatesGad then     DoDateBox = DSR_GadInfo1
  2810.       when DSR_GadID == ImagesGad then       DoImages = DSR_GadInfo1
  2811.       when DSR_GadID == MatchColorsGad then  DoMatchColors = DSR_GadInfo1
  2812.       when DSR_GadID == DailyColorsGad then  DoDailyColors = DSR_GadInfo1
  2813.     /**/
  2814.  
  2815.     /***//*** FontValGad ***/
  2816.       when DSR_GadID == FontValGad then do
  2817.         if DSR_GadInfo1 ~= value(CurrentFontName) then do
  2818.           call ToPIPE('CA', 'id 0 s=256')
  2819.           call CASimpleReq('FWCalendar 'Notice$, MustUse$)
  2820.           call ToPIPE('CA', 'id 0 s=512')
  2821.           call ToPIPE('CA', 'id 'FontValGad' gt="'value(CurrentFontName)'" page='ClickTab' refresh')
  2822.         end
  2823.       end
  2824.     /**/
  2825.  
  2826.     /***//*** ChooseFontGad ***/
  2827.       when DSR_GadID == ChooseFontGad then do
  2828.         if App == 'FW' then do
  2829.           DSR_File = CAGetFile('CA', GetFileAllGad, SelectFont$, CurrentDir'FWFonts/SWOLFonts/')
  2830.           if DSR_File ~= '' then do
  2831.             interpret CurrentFontName" = "QuoteIt(DSR_File)
  2832.             call ToPIPE('CA', 'id 'FontValGad' gt="'value(CurrentFontName)'" page='ClickTab' refresh')
  2833.           end
  2834.         end
  2835.         else if App == 'PGS' then do
  2836.           call ToPIPE('CA', 'id 0 s=256')
  2837.           interpret CurrentFontName" = "QuoteIt(ReadBrowserList('FontReq', 'FontGad', 'FontList', value(CurrentFontName)))
  2838.           call ToPIPE('CA', 'id 'FontValGad' gt="'value(CurrentFontName)'" page='ClickTab' refresh')
  2839.           call ToPIPE('CA', 'id 0 s=512')
  2840.         end
  2841.       end
  2842.     /**/
  2843.  
  2844.     /***//*** FontVarGad ***/
  2845.       when DSR_GadID == FontVarGad then do
  2846.         CurrentFontName = FontVarName.DSR_GadInfo1
  2847.         call ToPIPE('CA', 'id 'FontValGad' gt="'value(CurrentFontName)'" page='ClickTab' refresh')
  2848.       end
  2849.     /**/
  2850.  
  2851.     /***//*** ColorVarGad ***/
  2852.       when DSR_GadID == ColorVarGad then do
  2853.         call ToPIPE('CA', 'id 0 s=256')
  2854.         CurrentColorName = ReadBrowserList('ColorVarReq', 'ColorVarGad', 'ColorVarName', CurrentColorName)
  2855.         call ToPIPE('CA', 'id 'ColorVarGad' gt="'CurrentColorName'" page='ClickTab)
  2856.         call ToPIPE('CA', 'id 'ColorValGad' gt="'value(CurrentColorName)'" page='ClickTab)
  2857.         call ToPIPE('CA', 'id 0 s=512')
  2858.       end
  2859.     /**/
  2860.  
  2861.     /***//*** CycleColorVarGad ***/
  2862.       when DSR_GadID == CycleColorVarGad then do
  2863.         CurrentColorNum = MemberID(CurrentColorName, 'ColorVarName')
  2864.         if ShiftDown == 1 then do
  2865.           CurrentColorNum = CurrentColorNum - 1
  2866.           if CurrentColorNum < 0 then CurrentColorNum = ColorVarName.Count - 1
  2867.         end
  2868.         else do
  2869.           CurrentColorNum = CurrentColorNum + 1
  2870.           if CurrentColorNum = ColorVarName.Count then CurrentColorNum = 0
  2871.         end
  2872.         CurrentColorName = ColorVarName.CurrentColorNum
  2873.         call ToPIPE('CA', 'id 'ColorVarGad' gt="'CurrentColorName'" page='ClickTab)
  2874.         call ToPIPE('CA', 'id 'ColorValGad' gt="'value(CurrentColorName)'" page='ClickTab)
  2875.       end
  2876.     /**/
  2877.  
  2878.     /***//*** ColorValGad ***/
  2879.       when DSR_GadID == ColorValGad then do
  2880.         call ToPIPE('CA', 'id 0 s=256')
  2881.         if pos('BACKGROUND.', upper(CurrentColorName)) == 0 then CurrentColor = ReadBrowserList('NCColorReq', 'NCColorGad', 'NCColorList')
  2882.         else CurrentColor = ReadBrowserList('ColorReq', 'ColorGad', 'ColorList')
  2883.         interpret CurrentColorName' = "'CurrentColor'"'
  2884.         call ToPIPE('CA', 'id 'ColorValGad' gt="'CurrentColor'" page='ClickTab)
  2885.         call ToPIPE('CA', 'id 0 s=512')
  2886.       end
  2887.     /**/
  2888.  
  2889.     /***//*** MiscVarGad ***/
  2890.       when DSR_GadID == MiscVarGad then do
  2891.         call ProcessMiscValGad(ReadCAGad('CA', MiscValGad))
  2892.         call ToPIPE('CA', 'id 0 s=256')
  2893.         CurrentMiscName = ReadBrowserList('MiscVarReq', 'MiscVarGad', 'MiscVarName', CurrentMiscName)
  2894.         call UpdateMiscVarGad
  2895.         call ToPIPE('CA', 'id 0 s=512')
  2896.       end
  2897.     /**/
  2898.  
  2899.     /***//*** CycleMiscVarGad ***/
  2900.       when DSR_GadID == CycleMiscVarGad then do
  2901.         call ProcessMiscValGad(ReadCAGad('CA', MiscValGad))
  2902.         CurrentMiscNum = MemberID(CurrentMiscName, 'MiscVarName')
  2903.         if ShiftDown == 1 then do
  2904.           CurrentMiscNum = CurrentMiscNum - 1
  2905.           if CurrentMiscNum < 0 then CurrentMiscNum = MiscVarName.Count - 1
  2906.         end
  2907.         else do
  2908.           CurrentMiscNum = CurrentMiscNum + 1
  2909.           if CurrentMiscNum = MiscVarName.Count then CurrentMiscNum = 0
  2910.         end
  2911.         CurrentMiscName = MiscVarName.CurrentMiscNum
  2912.         call UpdateMiscVarGad
  2913.       end
  2914.     /**/
  2915.  
  2916.     /***//*** MiscValGad ***/
  2917.       when DSR_GadID == MiscValGad then do
  2918.         if VarReqGad == 0 then do
  2919.           if left(upper(CurrentMiscName), 11) == 'IMAGECLASS.' then do
  2920.             if DSR_GadInfo1 ~= '' then do
  2921.               call ToPIPE('CA', 'id 0 s=256')
  2922.               call CASimpleReq('FWCalendar 'Notice$, MustUse$)
  2923.               call ToPIPE('CA', 'id 0 s=512')
  2924.               IC = MemberID(upper(substr(CurrentMiscName, 12)), 'ImageClass')
  2925.               call ToPIPE('CA', 'id 'MiscValGad' gt="'ImageFile.IC'" page='ClickTab' refresh')
  2926.             end
  2927.             else do
  2928.               IC = MemberID(upper(substr(CurrentMiscName, 12)), 'ImageClass')
  2929.               call ToPIPE('CA', 'id 'MiscValGad' gt="" page='ClickTab' ref')
  2930.               interpret "ImageFile."IC" = DSR_GadInfo1"
  2931.             end
  2932.           end
  2933.           else do
  2934.             call ToPIPE('CA', 'id 0 s=256')
  2935.             call CASimpleReq('FWCalendar 'Notice$, MustUse$)
  2936.             call ToPIPE('CA', 'id 0 s=512')
  2937.             call ToPIPE('CA', 'id 'MiscValGad' gt="'value(CurrentMiscName)'" page='ClickTab' refresh')
  2938.           end
  2939.         end
  2940.         else call ProcessMiscValGad(DSR_GadInfo1)
  2941.       end
  2942.     /**/
  2943.  
  2944.     /***//*** ChooseValGad ***/
  2945.       when DSR_GadID == ChooseValGad then do
  2946.  
  2947.         if (upper(CurrentMiscName) == 'GFXAPPPATH') | (upper(CurrentMiscName) == 'GFXAPP') then do
  2948.           DSR_File = CAGetFile('CA', GetFileAllGad, SelectApp$, CheckDir(GfxAppPath))
  2949.           if DSR_File ~= '' then do
  2950.             PathPart = pathpart(DSR_File)
  2951.             FilePart = filepart(DSR_File)
  2952.             if upper(CurrentMiscName) == 'GFXAPPPATH' then call ToPIPE('CA', 'id 'MiscValGad' gt="'PathPart'" page='ClickTab' refresh')
  2953.             else call ToPIPE('CA', 'id 'MiscValGad' gt="'FilePart'" page='ClickTab' ref')
  2954.             interpret 'GfxAppPath = 'QuoteIt(PathPart)
  2955.             interpret 'GfxApp = 'QuoteIt(FilePart)
  2956.             if (exists(GfxAppPath''GfxApp)) & (~exists(Storage''GfxApp)) then address command 'copy 'GfxAppPath''GfxApp' 'Storage
  2957.             if exists(Storage''GfxApp) then call ToPIPE('CA', 'id 'ImagesGad' dis=0 page='ClickTab' refresh')
  2958.           end
  2959.         end
  2960.  
  2961.         else if pos('IMAGECLASS.', upper(CurrentMiscName)) > 0 then do
  2962.           IC = MemberID(upper(substr(CurrentMiscName, 12)), 'ImageClass')
  2963.           DSR_File = CAGetFile('CA', GetFileAllGad, SelectImage$, CheckDir(PathPart(ImageFile.IC)))
  2964.           if DSR_File ~= '' then do
  2965.             call ToPIPE('CA', 'id 'MiscValGad' gt="'DSR_File'" page='ClickTab' ref')
  2966.             interpret "ImageFile."IC" = DSR_File"
  2967.           end
  2968.         end
  2969.  
  2970.         else do
  2971.           if upper(CurrentMiscName) == 'SUNCALCPATH' then do
  2972.             DSR_File = CAGetFile('CA', GetFileAllGad, SelectApp$, CheckDir(SunCalcPath))
  2973.             if DSR_File ~= '' then do
  2974.               PathPart = pathpart(DSR_File)
  2975.               call ToPIPE('CA', 'id 'MiscValGad' gt="'PathPart'" page='ClickTab' ref')
  2976.               interpret 'SuncalcPath = 'QuoteIt(PathPart)
  2977.               if (exists(SuncalcPath'suncalc') == 1) & (exists(Storage'Suncalc') == 0) then address command 'copy 'SunCalcPath'suncalc 'Storage
  2978.               if exists(Storage'SunCalc') == 1 then do
  2979.                 do DSR_Grp = 0 to GroupCount
  2980.                   call ToPIPE('CA', 'id 'Gad.DSR_Grp.6' dis=0 page='ClickTab' ref')
  2981.                   call ToPIPE('CA', 'id 'Gad.DSR_Grp.7' dis=0 page='ClickTab' ref')
  2982.                   call ToPIPE('CA', 'id 'Gad.DSR_Grp.8' dis=0 page='ClickTab' ref')
  2983.                 end
  2984.               end
  2985.             end
  2986.           end
  2987.         end
  2988.       end
  2989.     /**/
  2990.  
  2991.     /***//*** HighlightEditGad ***/
  2992.       when DSR_GadID == HighlightEditGad then do
  2993.         EH_SelectMonth = Month
  2994.         call ToPIPE('CA', 'id 0 s=256')
  2995.         call EditHighlight_CA
  2996.         call ToPIPE('CA', 'id 0 s=512')
  2997.       end
  2998.     /**/
  2999.  
  3000.     /***//*** AddImageClassGad ***/
  3001.       when DSR_GadID == AddImageClassGad then do
  3002.         call ToPIPE('CA', 'id 0 s=256')
  3003.         call open('Req', "awnpipe:SimpleReq/xc")
  3004.         call ToPIPE('Req', '"'EnterNewIC$'" m v db dg si so a ps="'AppScreen'"')
  3005.         Req_StringGad = ToPIPE('Req', 'string cj minw=200 gt=""')
  3006.         call ToPIPE('Req', 'layout b=0 si so cj')
  3007.           call ToPIPE('Req', 'space')
  3008.           Req_DoneGad = ToPIPE('Req', 'button c gt="'OK$'"')
  3009.           call ToPIPE('Req', 'space')
  3010.         call ToPIPE('Req', 'le')
  3011.         call ToPIPE('Req', 'open')
  3012.         call ToPIPE('Req', 'id 'Req_StringGad' s=1')
  3013.  
  3014.         NewImageClass = ''
  3015.         do until eof('Req')
  3016.           call ToPIPE('Req', 'continue')
  3017.           Req_EventInfo = readln('Req')
  3018.           parse var Req_EventInfo Req_Event' 'Req_GadID' 'Req_GadInfo1
  3019.           if Req_Event == 'close' then NewImageClass = ReadCAGad('Req', Req_StringGad)
  3020.           if Req_GadID == Req_StringGad then NewImageClass = Req_GadInfo1
  3021.         end
  3022.         call close('Req')
  3023.         call ToPIPE('CA', 'id 0 s=512')
  3024.  
  3025.         if NewImageClass ~= '' then do
  3026.           ImageClass.ImgClassCount = NewImageClass
  3027.           NewImageFile = ''
  3028.           interpret "ImageFile."ImgClassCount" = NewImageFile"
  3029.           ImgClassCount = ImgClassCount + 1
  3030.  
  3031.           MiscVarName.MiscVarCount = 'ImageClass.'NewImageClass
  3032.           UpdateVarCmd.UpdateVarCmds = 'id 'MiscVarListID' addnode tar=-1 gt="ImageClass.'NewImageClass'"'
  3033.           UpdateVarNum.UpdateVarCmds = MiscVarCount
  3034.           UpdateVarCmds = UpdateVarCmds + 1
  3035.           MiscVarCount = MiscVarCount + 1
  3036.  
  3037.           MiscVarName.COUNT  = MiscVarCount
  3038.           ImageClass.COUNT   = ImgClassCount
  3039.           CurrentMiscName    = 'ImageClass.'NewImageClass
  3040.  
  3041.           call UpdateMiscVarGad
  3042.         end
  3043.       end
  3044.     /**/
  3045.  
  3046.       otherwise do
  3047.     /***//*** MX Gads ***/
  3048.         if symbol('DSR_Gad.DSR_GadID') == 'VAR' then do
  3049.           parse var DSR_Gad.DSR_GadID .'.'DSR_Grp'.'DSR_Posn
  3050.           if DSR_Grp ~= '' then call ControlMX(DSR_Grp, DSR_Posn)
  3051.         end
  3052.     /**/
  3053.       end
  3054.     end
  3055.     if (DSR_Event = 'gadget') & (ShiftDown = 1) & (symbol('GadText.DSR_GadID.1') == 'VAR') then do
  3056.       ShiftedGad = DSR_GadID
  3057.       OverGad = DSR_GadID
  3058.       call ToPIPE('CA', 'id 'ShiftedGad' gt="'GadText.ShiftedGad.1'"')
  3059.     end
  3060.   end
  3061.  
  3062.   Margin.Top    = ReadCAGad('CA', TopMargGad)
  3063.   Margin.Left   = ReadCAGad('CA', LeftMargGad)
  3064.   Margin.Right  = ReadCAGad('CA', RightMargGad)
  3065.   Margin.Bottom = ReadCAGad('CA', BottomMargGad)
  3066.  
  3067.   return
  3068.   /**/
  3069.  
  3070. /***//*** CA_Interpret MX ***/
  3071. CA_InterpretMX:
  3072.   do DSR_Posn = 0 to PosnCount
  3073.     interpret "Do"Do.DSR_Posn" = ''"
  3074.   end
  3075.   do DSR_Grp = 0 to GroupCount
  3076.     DSR_Posn = DSR_Sel.DSR_Grp
  3077.     interpret "Do"Do.DSR_Posn" = translate(DSR_Grp, 'BBBTT', '01234')||translate(DSR_Grp, 'LCRCR', '01234')"
  3078.   end
  3079.  
  3080.   if DoBothJ ~= '' then do
  3081.     DoJulian = DoBothJ
  3082.     DoJulianLeft = DoBothJ
  3083.   end
  3084.   if DoBothS ~= '' then do
  3085.     DoSunrise = DoBothS
  3086.     DoSunset = DoBothS
  3087.   end
  3088.   TopOption = sign(pos('T', DoPhases''DoWeeknumber''DoJulian''DoJulianLeft''DoSunrise''DoSunset))
  3089.  
  3090.   return
  3091. /**/
  3092.  
  3093. /***//*** ProcessMiscValGad ***/
  3094. ProcessMiscValGad:
  3095.   parse arg Value
  3096.   if datatype(Value) == 'CHAR' then Value = QuoteIt(Value)
  3097.   interpret CurrentMiscName' = 'Value
  3098.   if (upper(CurrentMiscName) == 'PREFSNAME') then do
  3099.     if PrefsName == '' then PrefsName = PrefsFile
  3100.     call ToPIPE('CA', 'id 'DisplayNameGad' gt="'value(CurrentMiscName)'" ref')
  3101.   end
  3102.   if HostScreen ~= '' then AppScreen = HostScreen
  3103.  
  3104.   return
  3105. /**/
  3106.  
  3107. /***//*** ReadMonthYearGads ***/
  3108. ReadMonthYearGads:
  3109.   if CalType == 1 then do
  3110.     Month = ReadCAGad('CA', SwitchGad1) + 1
  3111.     EnteredYear = ReadCAGad('CA', SwitchGad2)
  3112.   end
  3113.   else if CalType == 2 then do
  3114.     Month = ReadCAGad('CA', SwitchGad1) + 1
  3115.     EndMonth = ReadCAGad('CA', SwitchGad2) + 1
  3116.     EnteredYear = ReadCAGad('CA', SwitchGad3)
  3117.   end
  3118.   else EnteredYear = ReadCAGad('CA', SwitchGad2)
  3119.  
  3120.   return
  3121. /**/
  3122.  
  3123. /***//*** UpdateMiscVarGad ***/
  3124. UpdateMiscVarGad:
  3125.   call ToPIPE('CA', 'id 'MiscVarGad' gt="'CurrentMiscName'" page='ClickTab)
  3126.   if upper(left(CurrentMiscName, pos('.', CurrentMiscName))) == 'IMAGECLASS.' then do
  3127.     IC = MemberID(upper(substr(CurrentMiscName, 12)), 'ImageClass')
  3128.     call ToPIPE('CA', 'id 'MiscValGad' gt="'value("ImageFile.IC")'" page='ClickTab' refresh')
  3129.   end
  3130.   else call ToPIPE('CA', 'id 'MiscValGad' gt="'value(CurrentMiscName)'" page='ClickTab' refresh')
  3131.   UCMN = upper(CurrentMiscName)
  3132.   if (left(UCMN, 11) == 'IMAGECLASS.') | (UCMN == 'GFXAPPPATH') | (UCMN == 'SUNCALCPATH') | (UCMN == 'GFXAPP') then VarReqGad = 0
  3133.   else VarReqGad = 1
  3134.   call ToPIPE('CA', 'id 'ChooseValGad' dis='VarReqGad' page='ClickTab' refresh')
  3135.  
  3136.   return
  3137. /**/
  3138.  
  3139. /***//*** CA_UpdateGads ***/
  3140. CA_UpdateGads:
  3141.   if show('F', 'ProgReq') == 0 then Req = OpenBusy(PrepReq$, 12)
  3142.   call ToPIPE('CA', 'id 0 s=256')
  3143.   FontVarList     = ''
  3144.   ColorVarList    = ''
  3145.   CurrentColor    = 0
  3146.   CalType         = 1
  3147.   Month           = CalMonth
  3148.   EndMonth        = 12
  3149.   EnteredYear     = Year
  3150.   FontReq         = 0
  3151.   MiscVarReq      = 0
  3152.   ColorVarReq     = 0
  3153.   CurrentColorNum = 0
  3154.   CurrentMiscNum  = 0
  3155.   OverGad         = 0
  3156.   ShiftDown       = 0
  3157.   ShiftedGad      = 0
  3158.  
  3159.   DoBothS  = ''
  3160.   DoBothJ  = ''
  3161.  
  3162.   WarningCount = WarningsSoFar
  3163.   call ReadData
  3164.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  3165.  
  3166.   UCMN = upper(CurrentMiscName)
  3167.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  3168.  
  3169.   if DoExtended == 1 then do
  3170.     DoTopExtraWk = 0
  3171.     DoTopExtraWkDis = 1
  3172.     DoNoteBox = 0
  3173.     DoNoteBoxDis = 1
  3174.   end
  3175.   else do
  3176.     DoTopExtraWkDis = 0
  3177.     DoNoteBoxDis = 0
  3178.   end
  3179.  
  3180.   if (PrefsName == 'Default') & (PrefsFile ~= 'Default') then DisplayName = PrefsFile
  3181.   else DisplayName = PrefsName
  3182.  
  3183.   do DSR_Posn = 1 to PosnCount
  3184.     if (DSR_Posn == PhasesPosn) & (PhaseLib ~= 1) then iterate
  3185.     if (DSR_Posn == SunrisePosn) & (exists(Storage'suncalc') == 0) then iterate
  3186.     if (DSR_Posn == SunsetPosn) & (exists(Storage'suncalc') == 0) then iterate
  3187.     if (DSR_Posn == BothSPosn) & (exists(Storage'suncalc') == 0) then iterate
  3188.     if (DSR_Posn == RandomPosn) & (exists(ScriptDir'FWCRandom.txt') == 0) then iterate
  3189.     if (DSR_Posn == HistoryPosn) & (exists(ScriptDir'FWCHistory/01') == 0) then iterate
  3190.     interpret 'DoVariable = "Do'Do.DSR_Posn'"'
  3191.     if value(DoVariable) == 0 then interpret DoVariable " = ''"
  3192.     if value(DoVariable) ~= '' then do
  3193.       interpret DoVariable' = right(value(DoVariable), 2, "B")'
  3194.       DSR_Grp = translate(left(value(DoVariable), 1), '02', 'BT') + translate(right(value(DoVariable), 1), '012', 'LCR')
  3195.       GadSel.DSR_Grp.DSR_Posn = 1
  3196.       DSR_Sel.DSR_Grp = DSR_Posn
  3197.     end
  3198.   end
  3199.  
  3200.   do DSR_Grp = 0 to GroupCount
  3201.     if (GadSel.DSR_Grp.SunsetPosn == GadSel.DSR_Grp.SunrisePosn) & (GadSel.DSR_Grp.SunsetPosn == 1) then do
  3202.        GadSel.DSR_Grp.SunsetPosn  = 0
  3203.        GadSel.DSR_Grp.SunrisePosn = 0
  3204.        GadSel.DSR_Grp.BothSPosn   = 1
  3205.        DSR_Sel.DSR_Grp = BothSPosn
  3206.     end
  3207.     else if (GadSel.DSR_Grp.JulianPosn == GadSel.DSR_Grp.JulianLeftPosn) & (GadSel.DSR_Grp.JulianPosn == 1) then do
  3208.        GadSel.DSR_Grp.JulianPosn     = 0
  3209.        GadSel.DSR_Grp.JulianLeftPosn = 0
  3210.        GadSel.DSR_Grp.BothJPosn      = 1
  3211.        DSR_Sel.DSR_Grp = BothJPosn
  3212.     end
  3213.   end
  3214.  
  3215.   do DSR_Grp = 0 to GroupCount
  3216.     DSR_Posn = DSR_Sel.DSR_Grp
  3217.     GadSel.DSR_Grp.DSR_Posn = 1
  3218.   end
  3219.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  3220.  
  3221.   call close('MiscVarReq')
  3222.   call open('MiscVarReq', "awnpipe:MiscVarReq/xc")
  3223.   call ToPIPE('MiscVarReq', 'm dg v db a ps="'AppScreen'"')
  3224.   MiscVarListID = ToPIPE('MiscVarReq', 'listbrowser minw=200 minh=300')
  3225.   do DSR_i = 0 to MiscVarName.Count - 1
  3226.     GadID = ToPIPE('MiscVarReq', 'browsernode gt="'MiscVarName.DSR_i'"')
  3227.     interpret 'MiscVarGad.'GadID' = 'DSR_i
  3228.   end
  3229.   call UpdateMiscVarGad
  3230.  
  3231.   call close('ColorVarReq')
  3232.   call open('ColorVarReq', "awnpipe:ColorVarReq/xc")
  3233.   call ToPIPE('ColorVarReq', 'm dg v db a ps="'AppScreen'"')
  3234.   call ToPIPE('ColorVarReq', 'listbrowser minw=200 minh=300')
  3235.   do DSR_i = 0 to ColorVarName.Count - 1
  3236.     GadID = ToPIPE('ColorVarReq', 'browsernode gt="'ColorVarName.DSR_i'"')
  3237.     interpret 'ColorVarGad.'GadID' = 'DSR_i
  3238.   end
  3239.  
  3240.   do DSR_i = 0 to FontVarName.Count - 1
  3241.     FontVarList = FontVarList''FontVarName.DSR_i'|'
  3242.   end
  3243.  
  3244.   FontVarList = '"'strip(FontVarList, 'B', '|')'"'
  3245.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  3246.  
  3247.   call ToPIPE('CA', 'id 'DisplayNameGad' gt="'DisplayName'" ref')
  3248.   call ToPIPE('CA', 'id 'MiniCalsGad' s='DoMiniCals' page='ClickTab' ref')
  3249.   call ToPIPE('CA', 'id 'HighlightsGad' s='DoHighlights' page='ClickTab' ref')
  3250.   call ToPIPE('CA', 'id 'ImagesGad' dis='GfxDisable' s='DoImages' page='ClickTab' ref')
  3251.   call ToPIPE('CA', 'id 'BoxDatesGad' s='DoDateBox' page='ClickTab' ref')
  3252.   call ToPIPE('CA', 'id 'ExtendedGad' s='DoExtended' page='ClickTab' ref')
  3253.   call ToPIPE('CA', 'id 'TopLongGad' dis='DoTopExtraWkDis' s='DoTopExtraWk' page='ClickTab' ref')
  3254.   call ToPIPE('CA', 'id 'NoteBoxGad' dis='DoNoteBoxDis' s='DoNoteBox' page='ClickTab' ref')
  3255.   call ToPIPE('CA', 'id 'TopMargGad' gt="'Margin.Top'" page='ClickTab' ref')
  3256.   call ToPIPE('CA', 'id 'LeftMargGad' gt="'Margin.Left'" page='ClickTab' ref')
  3257.   call ToPIPE('CA', 'id 'OrientationGad' s='OrientChoice' page='ClickTab' ref')
  3258.   call ToPIPE('CA', 'id 'RightMargGad' gt="'Margin.Right'" page='ClickTab' ref')
  3259.   call ToPIPE('CA', 'id 'BottomMargGad' gt="'Margin.Bottom'" page='ClickTab' ref')
  3260.  
  3261.   call ToPIPE('CA', 'id 'CalendarTypeGad' s=0 ref')
  3262.   call AssignID('SwitchGad1', ToPIPE('CA', 'define chooser replace='SwitchGad1' pu cl='MonthList' s='Month - 1))
  3263.   call AssignID('SwitchGad2', ToPIPE('CA', 'define integer replace='SwitchGad2' a tc weiw=5 maxc=4 defn='EnteredYear))
  3264.   call AssignID('SwitchGad3', ToPIPE('CA', 'define button replace='SwitchGad3' b=0 gt=""'))
  3265.   call ToPIPE('CA', 'refresh')
  3266.   Help$.SwitchGad1Help = Help$.MonthGadHelp
  3267.   Help$.SwitchGad2Help = Help$.YearGadHelp
  3268.   Help$.SwitchGad3Help = ''
  3269.   call ToPIPE('CA', 'id 'SwitchGad1' s='Month - 1' ref')
  3270.   call ToPIPE('CA', 'id 'SwitchGad2' defn='EnteredYear' ref')
  3271.  
  3272.   call ToPIPE('CA', 'id 'FontVarGad' defn='FontVarName.COUNT' cl='FontVarList' page='ClickTab' ref')
  3273.   call ToPIPE('CA', 'id 'FontValGad' gt="'value(CurrentFontName)'" page='ClickTab' ref')
  3274.   call ToPIPE('CA', 'id 'ColorVarGad' gt="'CurrentColorName'" page='ClickTab' ref')
  3275.   call ToPIPE('CA', 'id 'ColorValGad' gt="'value(CurrentColorName)'" page='ClickTab' ref')
  3276.   call ToPIPE('CA', 'id 'MatchColorsGad' s='DoMatchColors' page='ClickTab' ref')
  3277.   call ToPIPE('CA', 'id 'DailyColorsGad' s='DoDailyColors' page='ClickTab' ref')
  3278.   call ToPIPE('CA', 'id 'MiscVarGad' gt="'CurrentMiscName'" page='ClickTab' ref')
  3279.   call ToPIPE('CA', 'id 'MiscValGad' gt="'VarVal'" page='ClickTab' ref')
  3280.   call ToPIPE('CA', 'id 'ChooseValGad' dis='VarReqGad' page='ClickTab' ref')
  3281.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  3282.  
  3283.   do DSR_Grp = 0 to GroupCount
  3284.     do DSR_Posn = 0 to PosnCount
  3285.       if datatype(Gad.DSR_Grp.DSR_Posn) == 'NUM' then call ToPIPE('CA', 'id 'Gad.DSR_Grp.DSR_Posn' dis='GadDis.DSR_Grp.DSR_Posn' s='GadSel.DSR_Grp.DSR_Posn' page='ClickTab' ref')
  3286.     end
  3287.     call ControlMX(DSR_Grp, DSR_Sel.DSR_Grp)
  3288.     if PhaseLib ~= 1 then call ToPIPE('CA', 'id 'Gad.DSR_Grp.PhasesPosn' dis=1 page='ClickTab' ref')
  3289.     if (~exists(ScriptDir'FWCRandom.txt')) & (datatype(Gad.DSR_Grp.RandomPosn) == 'NUM') then
  3290.       call ToPIPE('CA', 'id 'Gad.DSR_Grp.RandomPosn' dis=1 page='ClickTab' ref')
  3291.     if ~exists(ScriptDir'FWCHistory/01') & (datatype(Gad.DSR_Grp.HistoryPosn) == 'NUM') then
  3292.       call ToPIPE('CA', 'id 'Gad.DSR_Grp.HistoryPosn' dis=1 page='ClickTab' ref'))
  3293.     if ~exists(Storage'suncalc') then do
  3294.       call ToPIPE('CA', 'id 'Gad.DSR_Grp.SunRisePosn' dis=1 page='ClickTab' ref')
  3295.       call ToPIPE('CA', 'id 'Gad.DSR_Grp.SunSetPosn' dis=1 page='ClickTab' ref')
  3296.       call ToPIPE('CA', 'id 'Gad.DSR_Grp.BothSPosn' dis=1 page='ClickTab' ref')
  3297.     end
  3298.   end
  3299.   call ToPIPE('CA', 'id 0 s=512')
  3300.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  3301.  
  3302.   call close('ProgReq')
  3303.   return
  3304. /**/
  3305.  
  3306. /**/
  3307.  
  3308. /***//*** dTox (PROCEDURE) ***/
  3309. dTox:PROCEDURE
  3310. parse arg DecVal
  3311.  
  3312. BinVal = ''
  3313. HexVal = ''
  3314. do i = 32 to 0 by -1
  3315.   if DecVal >= 2**i then do
  3316.     BinVal = BinVal'1'
  3317.     DecVal = DecVal - 2**i
  3318.   end
  3319.   else BinVal = BinVal'0'
  3320. end
  3321.  
  3322. do until BinVal == ''
  3323.   HexVal = c2x(b2c(right(BinVal, 8, '0')))''HexVal
  3324.   if length(BinVal) >= 8 then CutLength = 8
  3325.   else CutLength = length(BinVal)
  3326.   BinVal = left(BinVal, length(BinVal) - CutLength)
  3327. end
  3328.  
  3329. return HexVal
  3330. /**/
  3331.  
  3332. /***//*** DrawBox (DB) ***/
  3333. DrawBox:
  3334.   parse arg DB_x1, DB_y1, DB_width, DB_height, DB_Weight, DB_LineColor, DB_FillBool, DB_FillColor, DB_SendToBack, DB_CornerRadius
  3335.  
  3336.   if DB_FillColor == '<'Clear$'>' then DB_FillBool = 0
  3337.  
  3338.   if App == 'FW' then do
  3339.     if DB_Weight == 'HL' then DB_Weight = 'Hairline'
  3340.     else if DB_Weight == 0 then do
  3341.       DB_Weight = 'None'
  3342.       if DB_FillColor ~= '<'Clear$'>' then DB_LineColor = DB_FillColor
  3343.     end
  3344.  
  3345.     if DB_FillBool == 1 then DB_FillBool = 'Solid'
  3346.     else do
  3347.       DB_FillBool = 'Transparent'
  3348.       DB_FillColor = DB_LineColor
  3349.     end
  3350.  
  3351.     if DB_CornerRadius == 0 then DB_BoxType = ''
  3352.     else DB_BoxType = 'BEVEL'
  3353.  
  3354.     BOXPREFS LINEWT DB_Weight LINECOLOR '"'DB_LineColor'"' FILL DB_FillBool FILLCOLOR '"'DB_FillColor'"'
  3355.     DRAWBOX 1 DB_x1 DB_y1 DB_width DB_height DB_BoxType; DB_id = result
  3356.     if DB_SendToBack == 1 then OBJECTTOBACK
  3357.   end
  3358.   else if App == 'PGS' then do
  3359.     if DB_Weight == 'HL' then DB_Weight = 0.3pt
  3360.     else DB_Weight = DB_Weight'pt'
  3361.  
  3362.     if DB_FillBool == 1 then DB_FillBool = 'ON'
  3363.     else DB_FillBool = 'OFF'
  3364.  
  3365.     If DB_Weight == 0 then DB_LineBool = 'OFF'
  3366.     else DB_LineBool = 'ON'
  3367.  
  3368.     if DB_CornerRadius == 0 then DB_BoxType = 'NORMAL'
  3369.     else DB_BoxType = 'ROUND'
  3370.  
  3371.     DRAWBOX DB_x1 DB_y1 DB_x1+DB_width DB_y1+DB_height DB_BoxType CORNER DB_CornerRadius WINDOW winName; DB_id = result
  3372.     STROKED DB_LineBool OBJECT WINDOW winName
  3373.     SETSTROKEWEIGHT DB_Weight STROKENUMBER 0 OBJECT WINDOW winName
  3374.     SETCOLORSTYLE '"'DB_LineColor'"' COLORNUMBER 0 STROKENUMBER 0 OBJECT WINDOW winName
  3375.     FILLED DB_FillBool OBJECT WINDOW winName
  3376.     SETCOLORSTYLE '"'DB_FillColor'"' COLORNUMBER 0 FILL OBJECT WINDOW winName
  3377.     if DB_SendToBack == 1 then SENDTOBACK OBJECTID DB_id WINDOW winName
  3378.   end
  3379.  
  3380.   return DB_id
  3381. /**/
  3382.  
  3383. /***//*** DrawHalf (DH) ***/
  3384. DrawHalf:
  3385.   parse arg DH_Side
  3386.  
  3387.   if App == 'FW' then do
  3388.     if DH_Side == 'L' then DH_sign = -1
  3389.     else DH_sign = 1
  3390.  
  3391.     STARTPATH 1 DM_CtrX (DM_CtrY + MoonRadius)
  3392.     CURVETO 1 (DM_CtrX + (DH_sign * MoonRadius * BelzierFactor)) (DM_CtrY + MoonRadius) (DM_CtrX + (DH_sign * MoonRadius)) (DM_CtrY + MoonRadius * BelzierFactor) (DM_CtrX + (DH_sign * MoonRadius)) DM_CtrY
  3393.     CURVETO 1 (DM_CtrX + (DH_sign * MoonRadius)) (DM_CtrY - MoonRadius * BelzierFactor) (DM_CtrX + (DH_sign * MoonRadius * BelzierFactor)) (DM_CtrY - MoonRadius) DM_CtrX (DM_CtrY - MoonRadius)
  3394.     ENDPATH Close
  3395.   end
  3396.   else if App == 'PGS' then do
  3397.     if DH_Side == 'L' then DRAWELLIPSE DM_CtrX DM_CtrY MoonRadius MoonRadius PIE ANGLES 90 270 WINDOW winName
  3398.     else DRAWELLIPSE DM_CtrX DM_CtrY MoonRadius MoonRadius PIE ANGLES 270 90 WINDOW winName
  3399.   end
  3400.  
  3401.   return result
  3402. /**/
  3403.  
  3404. /***//*** DrawLine (DL) ***/
  3405. DrawLine:
  3406.   parse arg DL_x1, DL_y1, DL_x2, DL_y2, DL_Weight, DL_Color
  3407.  
  3408.   if App == 'FW' then do
  3409.     if DL_Weight == 'HL' then DL_Weight = 'Hairline'
  3410.     else if DL_Weight == 0 then DL_Weight = 'None'
  3411.  
  3412.     LINEPREFS LINEWT DL_Weight LINECOLOR '"'DL_Color'"'
  3413.     DRAWLINE 1 DL_x1 DL_y1 DL_x2 DL_y2
  3414.   end
  3415.   else if App == 'PGS' then do
  3416.     if DL_Weight == 'HL' then DL_Weight = '0.3pt'
  3417.     else DL_Weight = DL_Weight'pt'
  3418.  
  3419.     DRAWLINE DL_x1 DL_y1 DL_x2 DL_y2 WINDOW winName; DL_id = result
  3420.     STROKED ON OBJECT WINDOW winName
  3421.     SETSTROKEWEIGHT DL_Weight STROKENUMBER 0 OBJECT
  3422.     SETCOLORSTYLE '"'DL_Color'"' COLORNUMBER 0 STROKENUMBER 0 OBJECT WINDOW winName
  3423.   end
  3424.  
  3425.   return result
  3426. /**/
  3427.  
  3428. /***//*** DrawMiniCal (DMC) ***/
  3429. DrawMiniCal:
  3430.   parse arg DMC_MiniDirection, DMC_CalWidth, DMC_FontType
  3431.  
  3432.   DMC_ColumnWidth = DMC_CalWidth/8
  3433.   DMC_BoxCount = 0
  3434.  
  3435.   DMC_MiniMonth = Month + DMC_MiniDirection
  3436.   if DMC_MiniMonth == 0 | DMC_MiniMonth == 13 then do
  3437.     DMC_MiniMonth = abs(DMC_MiniMonth - 12)
  3438.     Year = EnteredYear + DMC_MiniDirection
  3439.   end
  3440.   else Year = EnteredYear
  3441.   Mn = right(DMC_MiniMonth, 2, '0')
  3442.   if DoHighlights == 1 then call SetHighlights
  3443.  
  3444.   if DMC_MiniDirection < 0 then do
  3445.     DMC_StartColumn = StartDate - MonthLength.DMC_MiniMonth//7
  3446.     If DMC_StartColumn < 0 then DMC_StartColumn = DMC_StartColumn + 7
  3447.     DMC_MiniCalLeft = Margin.Left + ShiftLMini - CalendarBorder
  3448.   end
  3449.   else if DMC_MiniDirection > 0 then do
  3450.     DMC_StartColumn = StartDate + MonthLength.Month//7
  3451.     If DMC_StartColumn > 6 then DMC_StartColumn = DMC_StartColumn - 7
  3452.     DMC_MiniCalLeft = FullWidth - Margin.Right - DMC_CalWidth + ShiftRMini - CalendarShadow
  3453.   end
  3454.   else do
  3455.     DMC_StartColumn = StartDate
  3456.     DMC_MiniCalLeft = Margin.Left + c * (DMC_CalWidth + MiniCalSpacing)
  3457.   end
  3458.  
  3459.   /* Print Month & Year */
  3460.   DMC_ID.0 = CenterText(PrintText(1, Margin.Top, DMC_FontType, 'N', Color.MiniCal, Width.DMC_FontType, Month.DMC_MiniMonth' 'Year), DMC_MiniCalLeft + DMC_CalWidth/2, DMC_CalWidth, 0)
  3461.  
  3462.   /* Print Days */
  3463.   DMC_Column = DMC_StartColumn
  3464.   DMC_Day = 0
  3465.   DMC_Row = 1
  3466.   Do Until DMC_Day = MonthLength.DMC_MiniMonth
  3467.     DMC_Day = DMC_Day + 1
  3468.     DMC_Char1 = left(right(DMC_Day, 2, ' '), 1)
  3469.     DMC_Char2 = right(DMC_Day, 1)
  3470.     if (Highlight.DMC_MiniMonth.DMC_Day == '') | (symbol('Highlight.DMC_MiniMonth.DMC_Day') == 'LIT') then do
  3471.       DMC_Style = 'N'
  3472.       if CenterMiniDates == 1 then DMC_CenterAdj = (DMC_ColumnWidth - 2*NormalWidth.Widest)/2 + (NormalWidth.Widest * 2 - NormalWidth.DMC_Char1 - NormalWidth.DMC_Char2) / 2 + NormalWidth.DMC_Char1 + NormalWidth.DMC_Char2
  3473.       else DMC_CenterAdj = (DMC_ColumnWidth - 2*NormalWidth.Widest)/2 + (NormalWidth.Widest - NormalWidth.DMC_Char2) / 2 + NormalWidth.DMC_Char1 + NormalWidth.DMC_Char2
  3474.     end
  3475.     else do
  3476.       DMC_Style = 'B'
  3477.       if CenterMiniDates == 1 then DMC_CenterAdj = (DMC_ColumnWidth - 2*BoldWidth.Widest)/2 + (BoldWidth.Widest * 2 - BoldWidth.DMC_Char1 - BoldWidth.DMC_Char2) / 2 + BoldWidth.DMC_Char1 + BoldWidth.DMC_Char2
  3478.       else DMC_CenterAdj = (DMC_ColumnWidth - 2*BoldWidth.Widest)/2 + (BoldWidth.Widest - BoldWidth.DMC_Char2) / 2 + BoldWidth.DMC_Char1 + BoldWidth.DMC_Char2
  3479.     end
  3480.  
  3481.     DMC_Text.Right = (DMC_Column + 1.5) * DMC_ColumnWidth
  3482.     DMC_Text.Top   = Margin.Top + DMC_Row*Height.DMC_FontType
  3483.  
  3484.     DMC_Text.Left = DMC_MiniCalLeft + DMC_Text.Right - DMC_CenterAdj
  3485.     DMC_ID.DMC_Day = PrintText(DMC_Text.Left, DMC_Text.Top, DMC_FontType, DMC_Style, Color.MiniCal, Width.DMC_FontType, DMC_Day)
  3486.     if UpdateBusy(Req, 1) == -1 then call Cleanup
  3487.  
  3488.     if pos('#', Highlight.DMC_MiniMonth.DMC_Day) > 0 then do
  3489.       DMC_BoxCount = DMC_BoxCount + 1
  3490.       DMC_Box.Left = DMC_MiniCalLeft + (DMC_Column + .5) * DMC_ColumnWidth
  3491.       DMC_BoxID.DMC_BoxCount = DrawBox(DMC_Box.Left, DMC_Text.Top - (Height.DMC_FontType * ((1 - TextAdj) / 3) * (App == 'FW')), DMC_ColumnWidth, Height.DMC_FontType, 'HL', Line.MiniCal, 0, Black$, 1, 0)
  3492.       call BuryObject(DMC_BoxID.DMC_BoxCount)
  3493.     end
  3494.  
  3495.     DMC_Column = DMC_Column + 1
  3496.     if DMC_Column == 7 then do
  3497.       DMC_Column = 0
  3498.       DMC_Row = DMC_Row + 1
  3499.     end
  3500.   end
  3501.  
  3502.   if CalendarShadow ~= 0 then do
  3503.     if ShadowType == 'P' then do
  3504.       call DrawBox(DMC_MiniCalLeft + DMC_CalWidth, Margin.Top + CalendarShadow, CalendarShadow, 7*Height.DMC_FontType, 0, , 1, Background.MiniCalShadow, 1, 0)
  3505.       call DrawBox(DMC_MiniCalLeft + CalendarShadow, Margin.Top + 7*Height.DMC_FontType, DMC_CalWidth, CalendarShadow, 0, , 1, Background.MiniCalShadow, 1, 0)
  3506.     end
  3507.     else call DrawBox(DMC_MiniCalLeft + CalendarShadow, Margin.Top + CalendarShadow, DMC_CalWidth, 7*Height.DMC_FontType, 0, , 1, Background.MiniCalShadow, 1, CornerRadius * MiniCalWidth)
  3508.   end
  3509.   call DrawBox(DMC_MiniCalLeft, Margin.Top, DMC_CalWidth, 7*Height.DMC_FontType, 'HL', Line.MiniCal, 1, Background.MiniCal, 1, CornerRadius * MiniCalWidth)
  3510.  
  3511.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  3512.  
  3513.   if App == 'FW' then do
  3514.     REDRAW
  3515.     do DMC_i = 0 to MonthLength.DMC_MiniMonth; SELECTOBJECT DMC_ID.DMC_i MULTIPLE; End
  3516.     do DMC_i = 1 to DMC_BoxCount; SELECTOBJECT DMC_BoxID.DMC_i MULTIPLE; End
  3517.     GROUP
  3518.   end
  3519.   else if App == 'PGS' then do
  3520.     do DMC_i = 0 to MonthLength.DMC_MiniMonth; SELECTOBJECT ObjectID DMC_ID.DMC_i Add WINDOW winName; End
  3521.     do DMC_i = 1 to DMC_BoxCount; SELECTOBJECT ObjectID DMC_BoxID.DMC_i Add WINDOW winName; End
  3522.     GROUP WINDOW winName
  3523.   end
  3524. return
  3525. /**/
  3526.  
  3527. /***//*** DrawMoon (DM) ***/
  3528. DrawMoon:
  3529.   parse arg DM_Phase, DM_CtrX, DM_CtrY, DM_Color
  3530.  
  3531.   if App == 'FW' then do
  3532.     if (DM_Phase == 'N') | (DM_Phase == 'F') then do
  3533.       if DM_Phase == 'N' then DM_FillColor = DM_Color
  3534.       else DM_FillColor = White$
  3535.       OVALPREFS LINEWT 'Hairline' LINECOLOR '"'DM_Color'"' FILL 'Solid' FILLCOLOR '"'DM_FillColor'"'
  3536.       DRAWOVAL 1 (DM_CtrX - MoonRadius) (DM_CtrY - MoonRadius) (2 * MoonRadius) (2 * MoonRadius)
  3537.       DM_id = result
  3538.     end
  3539.     else do
  3540.       SHAPEPREFS LINEWT 'Hairline' LINECOLOR '"'DM_Color'"' FILL 'Solid' FILLCOLOR '"'DM_Color'"'
  3541.       if DM_Phase == 1 then DM_HalfID = DrawHalf('R')
  3542.       else DM_HalfID = DrawHalf('L')
  3543.       SHAPEPREFS FILLCOLOR '"'White$'"'
  3544.       if DM_Phase == 1 then DM_Half2ID = DrawHalf('L')
  3545.       else DM_Half2ID = DrawHalf('R')
  3546.       SELECTOBJECT DM_HalfID
  3547.       SELECTOBJECT DM_Half2ID Multiple
  3548.       GROUP
  3549.       CURRENTOBJECT; DM_id = result
  3550.     end
  3551.   end
  3552.   else if App == 'PGS' then do
  3553.     if (DM_Phase == 'N') | (DM_Phase == 'F') then do
  3554.       DRAWELLIPSE DM_CtrX DM_CtrY MoonRadius MoonRadius WINDOW winName
  3555.       DM_id = result
  3556.       if DM_Phase == 'N' then call SetFill(DM_id, DM_Color, DM_Color)
  3557.       else call SetFill(DM_id, DM_Color, White$)
  3558.     end
  3559.     else do
  3560.       DRAWELLIPSE DM_CtrX DM_CtrY MoonRadius MoonRadius PIE ANGLES 90 270 WINDOW winName
  3561.       DM_LHalfID = result
  3562.       if DM_Phase == 1 then call SetFill(DM_LHalfID, DM_Color, White$)
  3563.       else call SetFill(DM_LHalfID, DM_Color, DM_Color)
  3564.       DRAWELLIPSE DM_CtrX DM_CtrY MoonRadius MoonRadius PIE ANGLES 270 90 WINDOW winName
  3565.       DM_RHalfID = result
  3566.       if DM_Phase == 1 then call SetFill(DM_RHalfID, DM_Color, DM_Color)
  3567.       else call SetFill(DM_RHalfID, DM_Color, White$)
  3568.       SELECTOBJECT OBJECTID DM_LHalfID Add WINDOW winName
  3569.       GROUP WINDOW winName; DM_id = result
  3570.     end
  3571.   end
  3572.  
  3573.   return DM_id
  3574. /**/
  3575.  
  3576. /***//*** EditHighlight ***/
  3577. /***//*** EditHighlight_BGUI (EH) ***/
  3578. EditHighlight_BGUI:
  3579.   /***//*** Initialize Variables ***/
  3580.   EH_WeekendCyc.0     = "OK"
  3581.   EH_WeekendCyc.1     = "P"
  3582.   EH_WeekendCyc.2     = "N"
  3583.   EH_WeekendCyc.OK    = 0
  3584.   EH_WeekendCyc.P     = 1
  3585.   EH_WeekendCyc.N     = 2
  3586.  
  3587.   EH_WeekTypeCyc.0    = "All"
  3588.   EH_WeekTypeCyc.1    = "Odd"
  3589.   EH_WeekTypeCyc.2    = "Even"
  3590.   EH_WeekTypeCyc.All  = 0
  3591.   EH_WeekTypeCyc.Odd  = 1
  3592.   EH_WeekTypeCyc.Even = 2
  3593.  
  3594.   EH_HighlightTypeCyc.Fixed      = 0
  3595.   EH_HighlightTypeCyc.Float      = 1
  3596.   EH_HighlightTypeCyc.BiOrWeekly = 2
  3597.   EH_HighlightTypeCyc.0          = 'Fixed'
  3598.   EH_HighlightTypeCyc.1          = 'Float'
  3599.   EH_HighlightTypeCyc.2          = 'BiOrWeekly'
  3600.  
  3601.   EH_KeywordCode.00 = 'Highlight'
  3602.   EH_KeywordCode.01 = 'Image'
  3603.   EH_KeywordCode.10 = 'CalculateDate'
  3604.   EH_KeywordCode.11 = 'CalculateImage'
  3605.   EH_KeywordCode.20 = 'CalculateDate'
  3606.   EH_KeywordCode.21 = 'CalculateImage'
  3607.  
  3608.   EH_EntryCount   = 0
  3609.   EH_EventDay     = 0
  3610.  
  3611.   EH_Year = left(date('S'),4)
  3612.   interpret 'EH_StartYear = Day.'DateInfo('W', EH_Year'0101', 'S')
  3613.   EH_YearOffset = 7 - EH_StartYear
  3614.   if EH_YearOffset == 7 then EH_YearOffset = 0
  3615.  
  3616.   EH_SelectMonth = right(EH_SelectMonth, 2, '0')
  3617.   EH_MonthCount = MonthCount.EH_SelectMonth
  3618.   EH_Month = EH_SelectMonth - 0
  3619.   if EH_Month > 12 then EH_Month = 1
  3620.   EH_Month = right(EH_Month, 2, "0")
  3621.   EH_ShortMonth = EH_Month - 0
  3622.  
  3623.   interpret 'EH_StartDate = Day.'DateInfo('W', EH_Year''EH_Month'01', 'S')
  3624. /**/
  3625.  
  3626.   /***//*** EH_ReadData ***/
  3627.   /* Read data here */
  3628.   if EH_MonthCount > 0 then do
  3629.     do EH_j = 1 to EH_MonthCount
  3630.       EH_EntryCount = EH_EntryCount + 1
  3631.       if EH_SelectMonth < 14 then CurrentData.EH_SelectMonth.EH_j = substr(HighlightData.EH_SelectMonth.EH_j, 3)
  3632.       else CurrentData.EH_SelectMonth.EH_j = HighlightData.EH_SelectMonth.EH_j
  3633.       if symbol('CurrentData.EH_SelectMonth.EH_j') == 'VAR' then do
  3634.         EH_HighlightData = strip(CurrentData.EH_SelectMonth.EH_j)
  3635.         if right(EH_HighlightData, 2) == '*/' then do
  3636.           EH_StartComment = lastpos('/*', EH_HighlightData)
  3637.           EH_Comment.EH_EntryCount = strip(substr(EH_HighlightData, EH_StartComment), 'B', ' /*')
  3638.           EH_HighlightData = strip(left(EH_HighlightData, EH_StartComment - 1))
  3639.         end
  3640.         else EH_Comment.EH_EntryCount = ''
  3641.  
  3642.         EH_Keyword = word(EH_HighlightData, 1)
  3643.         EH_FirstDot = pos('.', EH_Keyword)
  3644.         EH_FirstParen = pos('(', EH_Keyword)
  3645.         if EH_FirstDot == 0 then EH_EndOfKeyword = EH_FirstParen
  3646.         else if EH_FirstParen == 0 then EH_EndOfKeyword = EH_FirstDot
  3647.         else EH_EndOfKeyword = min(pos('.', EH_Keyword), pos('(', EH_Keyword))
  3648.         EH_Keyword.EH_EntryCount = left(EH_Keyword, EH_EndOfKeyword - 1)
  3649.         if (upper(EH_Keyword.EH_EntryCount) == 'HIGHLIGHT') | (upper(EH_Keyword.EH_EntryCount) == 'IMAGE') then do
  3650.           EH_HighlightType.EH_EntryCount = 'Fixed'
  3651.           EH_EventDay.EH_EntryCount = substr(EH_Keyword, lastpos('.', EH_Keyword) + 1)
  3652.           EH_Event.EH_EntryCount = substr(EH_HighlightData, pos('=', EH_HighlightData) + 1)
  3653.           parse var EH_Event.EH_EntryCount EH_Event.EH_EntryCount','EH_Color.EH_EntryCount
  3654.           if upper(EH_Keyword.EH_EntryCount) == 'IMAGE' then do
  3655.             if (pos(':', EH_Event.EH_EntryCount) == 0) & (pos('/', EH_Event.EH_EntryCount) == 0) then
  3656.               EH_Event.EH_EntryCount = ScriptDir'Images/'strip(EH_Event.EH_EntryCount, 'B', ' "'||"'")
  3657.           end
  3658.         end
  3659.         else do
  3660.           EH_HighlightData = strip(substr(EH_HighlightData, EH_EndOfKeyword + 1), 'B', ')')
  3661.           if EH_SelectMonth == 14 then do
  3662.             parse var EH_HighlightData EH_EventDay.EH_EntryCount','EH_Event.EH_EntryCount','EH_Color.EH_EntryCount
  3663.             EH_EventDay.EH_EntryCount = strip(EH_EventDay.EH_EntryCount)
  3664.             EH_Event.EH_EntryCount = strip(EH_Event.EH_EntryCount)
  3665.             EH_HighlightType.EH_EntryCount = 'Easter'
  3666.             EH_Keyword.EH_EntryCount = 'CalculateEDate'
  3667.           end
  3668.           else do
  3669.             parse var EH_HighlightData .','EH_DayOfWeek','EH_HighDate','EH_Event.EH_EntryCount','EH_Color.EH_EntryCount
  3670.             interpret "EH_DayOfWeek = Day."strip(EH_DayOfWeek, 'B', ' "'||"'")
  3671.             EH_HighDate = strip(EH_HighDate)
  3672.             EH_Event.EH_EntryCount = strip(EH_Event.EH_EntryCount)
  3673.             if pos('IMAGE', upper(EH_Keyword.EH_EntryCount)) > 0 then do
  3674.               if (pos(':', EH_Event.EH_EntryCount) == 0) & (pos('/', EH_Event.EH_EntryCount) == 0) then do
  3675.                 EH_Event.EH_EntryCount = ScriptDir'Images/'strip(EH_Event.EH_EntryCount, 'B', ' "'||"'")
  3676.               end
  3677.             end
  3678.             if datatype(EH_HighDate) == 'CHAR' then do
  3679.               /* Weekly/Biweekly events */
  3680.               EH_HighlightType.EH_EntryCount = 'BiOrWeekly'
  3681.               EH_WeekType.EH_EntryCount = strip(upper(EH_HighDate), 'B', "'")
  3682.               EH_EventOffset = EH_DayOfWeek - EH_StartDate
  3683.               EH_EventDay.EH_EntryCount  = 1 + EH_EventOffset
  3684.               if EH_EventDay.EH_EntryCount < 1 then EH_EventDay.EH_EntryCount = EH_EventDay.EH_EntryCount + 7
  3685.               EH_WN = trunc((right(DateInfo('J', EH_Year''EH_Month''right(EH_EventDay.EH_EntryCount, 2, '0'), 'S'), 3) - EH_YearOffset - 1)/7 + 1)
  3686.               if ((EH_WeekType.EH_EntryCount == 'EVEN') & (EH_WN//2 == 1)) | ((EH_WeekType.EH_EntryCount == 'ODD') & (EH_WN//2 == 0)) then EH_EventDay.EH_EntryCount = EH_EventDay.EH_EntryCount + 7
  3687.             end
  3688.             else do
  3689.               EH_HighlightType.EH_EntryCount = 'Float'
  3690.               interpret 'EH_First = Day.'DateInfo('W', EH_Year''EH_Month'01', 'S')
  3691.               EH_EventDay.EH_EntryCount = EH_HighDate + (EH_DayOfWeek - EH_First)
  3692.               if EH_First < EH_DayOfWeek then EH_EventDay.EH_EntryCount = EH_EventDay.EH_EntryCount - 7
  3693.               EH_TempDay = EH_EventDay.EH_EntryCount
  3694.               EH_Weeknumber.EH_EntryCount = 0
  3695.               if EH_HighDate > 28 then EH_Weeknumber.EH_EntryCount = 4
  3696.               else do
  3697.                 do until EH_TempDay < 0
  3698.                   EH_TempDay = EH_TempDay - 7
  3699.                   if EH_TempDay > 0 then EH_Weeknumber.EH_EntryCount = EH_Weeknumber.EH_EntryCount + 1
  3700.                 end
  3701.               end
  3702.             end
  3703.           end
  3704.         end
  3705.  
  3706.         if datatype(EH_EventDay.EH_EntryCount) == 'CHAR' then do
  3707.           EH_Weekend.EH_EntryCount = upper(right(EH_EventDay.EH_EntryCount, 1))
  3708.           EH_EventDay.EH_EntryCount = left(EH_EventDay.EH_EntryCount, length(EH_EventDay.EH_EntryCount) - 1)
  3709.         end
  3710.         else EH_Weekend.EH_EntryCount = 'OK'
  3711.  
  3712.         if EH_EventDay.EH_EntryCount == '32' then EH_EventDay.EH_EntryCount = 'LD'
  3713.  
  3714.         EH_Event.EH_EntryCount = strip(EH_Event.EH_EntryCount, 'B', ' "'||"'")
  3715.         if right(EH_Event.EH_EntryCount, 1) == '#' then do
  3716.           EH_Holiday.EH_EntryCount = 128
  3717.           EH_Event.EH_EntryCount = left(EH_Event.EH_EntryCount, length(EH_Event.EH_EntryCount) - 1)
  3718.         end
  3719.         else EH_Holiday.EH_EntryCount = 0
  3720.       end
  3721.       EH_Color.EH_EntryCount = strip(EH_Color.EH_EntryCount, 'B', ' "'||"'")
  3722.       EH_Color.EH_EntryCount = MemberID(EH_Color.EH_EntryCount, 'ColorList')
  3723.       if EH_Color.EH_EntryCount == -1 then EH_Color.EH_EntryCount = ColorList.COUNT
  3724.  
  3725.       do EH_k = 1 to EH_EntryCount - 1
  3726.         EH_Seq = EH_Pointer.EH_k
  3727.         if EH_EventDay.EH_EntryCount < EH_EventDay.EH_Seq then do
  3728.           do EH_l = EH_EntryCount - 1 to EH_k by -1
  3729.             EH_Next = EH_l + 1
  3730.             EH_Pointer.EH_Next = EH_Pointer.EH_l
  3731.           end
  3732.         leave
  3733.         end
  3734.       end
  3735.       EH_Pointer.EH_k = EH_EntryCount
  3736.     end
  3737.   end
  3738.  
  3739.   EH_HighEntry = EH_EntryCount
  3740.   if EH_EntryCount > 0 then do
  3741.     EH_CurrentPointer = 1
  3742.     EH_CurrentEntry = EH_Pointer.EH_CurrentPointer
  3743.   end
  3744.   else do
  3745.     EH_CurrentEntry = 0
  3746.     EH_CurrentPointer = 0
  3747.   end
  3748.   EH_DayShowing = 0
  3749.   /**/
  3750.  
  3751.   /***//*** GUI Description ***/
  3752.   GadID.  = ''
  3753.   EH_Arg. = ''
  3754.   EH_i    = 0
  3755.   EH_Day  = 0
  3756.   Req     = OpenBusy(PrepReq$, 45)
  3757.   do while (EH_i < 6)
  3758.     EH_j = 0
  3759.     do while (EH_j < 7)
  3760.       if UpdateBusy(Req, 1) == -1 then call Cleanup
  3761.       EH_SerialPosition = (EH_i * 7) + EH_j
  3762.       EH_Button = EH_SerialPosition + 1
  3763.       if (EH_SerialPosition >= EH_StartDate) & (EH_SerialPosition < EH_StartDate + MonthLength.EH_ShortMonth + 1) then Do
  3764.         EH_Day = EH_Day + 1
  3765.         if EH_Day > MonthLength.EH_ShortMonth then EH_Day = LD
  3766.         interpret "GadID."EH_Button" = bguitoggle('"EH_Button"_', EH_Day)"
  3767.         GadID = GetID(EH_Button'_')
  3768.         EH_Button.EH_Button = GadID
  3769.         EH_Arg.GadID = EH_Day
  3770.         EH_ButtonID.EH_Day = EH_Button
  3771.       end
  3772.       else do
  3773.           interpret "GadID."EH_Button" = bguibutton('"EH_Button"_', '')"
  3774.           GadID = GetID(EH_Button'_')
  3775.           EH_Button.EH_Button = GadID
  3776.           EH_Arg.GadID = 'dummy'
  3777.       end
  3778.       EH_j = EH_j + 1
  3779.     end
  3780.     EH_i = EH_i + 1
  3781.     if EH_SerialPosition >= EH_StartDate + MonthLength.EH_ShortMonth then leave
  3782.   end
  3783.  
  3784.   DateButtons = bguihgroup(GadID.1""GadID.2""GadID.3""GadID.4""GadID.5""GadID.6""GadID.7)||,
  3785.                 bguihgroup(GadID.8""GadID.9""GadID.10""GadID.11""GadID.12""GadID.13""GadID.14)||,
  3786.                 bguihgroup(GadID.15""GadID.16""GadID.17""GadID.18""GadID.19""GadID.20""GadID.21)||,
  3787.                 bguihgroup(GadID.22""GadID.23""GadID.24""GadID.25""GadID.26""GadID.27""GadID.28)
  3788.   if EH_i > 4 then DateButtons = DateButtons''bguihgroup(GadID.29""GadID.30""GadID.31""GadID.32""GadID.33""GadID.34""GadID.35)
  3789.   if EH_i > 5 then DateButtons = DateButtons''bguihgroup(GadID.36""GadID.37""GadID.38""GadID.39""GadID.40""GadID.41""GadID.42)
  3790.  
  3791.   call bguilist("EH_monthlist_", January$, February$, March$, April$, May$, June$, July$, August$, September$, October$, November$, December$, All$, Easter$)
  3792.   call bguilist("EH_highlighttypelist_", Fixed$, Floating$, BiOrWeekly$)
  3793.   call bguilist("EH_weeknumberlist_", First$, Second$, Third$, Fourth$, Last$)
  3794.   call bguilist("EH_weektypelist_", All$, Odd$, Even$)
  3795.   call bguilist("EH_weekendlist_", OK2$, PreviousDay$, NextDay$)
  3796.  
  3797.   EH_g=bguivgroup(,
  3798.     bguihgroup(,
  3799.       bguistring("EH_event_",Event$":","",256)bguilayout(LGO_FixMinHeight,1)||,
  3800.       bguiibutton('EH_eventimage_','B','F')bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight, 1)||,
  3801.       bguibutton('EH_prev_','<')bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight, 1)||,
  3802.       bguibutton("EH_next_",'>')bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight,1),
  3803.     )||,
  3804.     bguihgroup(,
  3805.       bguistring('EH_comment_',Comment$":","",256)bguilayout(LGO_FixMinHeight,1),
  3806.     )||,
  3807.     bguihgroup(,
  3808.       bguivgroup(,
  3809.         bguihgroup(,
  3810.           bguivarspace(40)||,
  3811.           bguicycle('changemonth_',,"EH_monthlist_",'P')bguilayout(LGO_FixMinHeight, 1)||,
  3812.           bguivarspace(40),
  3813.         )||,
  3814.         bguihgroup(,
  3815.           bguiinfo("EH_dummy_",,esc"c"left(Day.0,1))||,
  3816.           bguiinfo("EH_dummy_",,esc"c"left(Day.1,1))||,
  3817.           bguiinfo("EH_dummy_",,esc"c"left(Day.2,1))||,
  3818.           bguiinfo("EH_dummy_",,esc"c"left(Day.3,1))||,
  3819.           bguiinfo("EH_dummy_",,esc"c"left(Day.4,1))||,
  3820.           bguiinfo("EH_dummy_",,esc"c"left(Day.5,1))||,
  3821.           bguiinfo("EH_dummy_",,esc"c"left(Day.6,1)),
  3822.         )||,
  3823.         DateButtons,
  3824.       )||,
  3825.       bguivgroup(,
  3826.         bguivarspace(40)||,
  3827.         bguicycle('EH_highlightcolor_',esc"r"Color$':','ColorList','P')bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight, 1)||,
  3828.         bguicycle('EH_highlighttype_',esc"r"Type$':','EH_highlighttypelist_','P')bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight, 1)||,
  3829.         bguicycle("EH_weeknumber_",esc"r"WeekNumber$':',"EH_weeknumberlist_",'P')bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight,1)||,
  3830.         bguicycle('EH_weektype_',esc"r"WeekType$":",'EH_weektypelist_','P')bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight, 1)||,
  3831.         bguicycle("EH_weekend_",esc"r"Weekend$":",'EH_weekendlist_','P')bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight,1)||,
  3832.         bguicheckbox("EH_holiday_",esc"r"Holiday$":",0)bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight,1)||,
  3833.         bguihgroup(,
  3834.           bguistring("EH_easter_",Easter$':',,4)bguilayout(LGO_FixMinHeight,1)||,
  3835.           bguivarspace(40),
  3836.         )||,
  3837.         bguihgroup(,
  3838.           bguibutton("EH_new_",AddEvent$)bguilayout(LGO_FixMinHeight,1)||,
  3839.           bguibutton("EH_delete_",DeleteEvent$)bguilayout(LGO_FixMinHeight,1),
  3840.         )||,
  3841.         bguihgroup(,
  3842.           bguibutton("EH_done_",Done$)bguilayout(LGO_FixMinHeight,1),
  3843.         ),
  3844.       ),
  3845.     ),
  3846.   ,"-1","-1")
  3847.  
  3848.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  3849.   EH_winID=bguiwindow(EnterEventInfo$,EH_g,5,0,,AppScreen)
  3850.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  3851.  
  3852.   call bguiwintabcycleorder(EH_winID,obj.EH_event_||obj.EH_comment_)
  3853.   if EH_EntryCount == 0 then call EH_GhostGads
  3854.   else if EH_SelectMonth == 14 then do
  3855.     call EH_GhostGads
  3856.     call EH_SetGads
  3857.   end
  3858.   else do
  3859.     do EH_i = 1 to EH_Button
  3860.       EH_temp = EH_Button.EH_i
  3861.       if EH_Arg.EH_temp == 'dummy' then interpret "call bguiset(obj."EH_i"_,EH_winID, GA_Disabled, 1)"
  3862.     end
  3863.   end
  3864.  
  3865.   call bguiset(obj.changemonth_,EH_winID,CYC_Active,EH_SelectMonth - 1)
  3866.   /**/
  3867.  
  3868.   /***//*** GUI Action Loop ***/
  3869.   EH_CurrentEntry = EH_Pointer.EH_CurrentPointer
  3870.   call EH_SetRequester
  3871.   if EH_EntryCount > 0 then EH_DayShowing = EH_EventDay.EH_CurrentEntry
  3872.   if bguiwinopen(EH_winID)=0 then bguierror(12)
  3873.  
  3874.   call CloseBusy(Req)
  3875.  
  3876.   id=0
  3877.   EH_Done = 0
  3878.   do until EH_Done ~= 0
  3879.     call bguiwinwaitevent(EH_winID,"ID")
  3880.     select
  3881.     /***//*** Close ***/
  3882.       when (id == id.EH_cancel_) | (id == id.winclose) then do
  3883.         call bguiwinclose(EH_winID)
  3884.         EH_Done = 1
  3885.       end
  3886.     /**/
  3887.  
  3888.     /***//*** Done ***/
  3889.       when id == id.EH_done_ then do
  3890.         call EH_ReadSettings
  3891.         call EH_SaveHighlightData
  3892.         call bguiwinclose(EH_winID)
  3893.         EH_Done = 1
  3894.       end
  3895.     /**/
  3896.  
  3897.     /***//*** EH_EventGad ***/
  3898.       when id == id.EH_event_ then EH_Event.EH_CurrentEntry = bguiget(obj.EH_event_, STRINGA_TextVal)
  3899.     /**/
  3900.  
  3901.     /***//*** EH_PrevGad ***/
  3902.       when id == id.EH_prev_ then do
  3903.         call EH_ReadSettings
  3904.         EH_CurrentPointer = EH_CurrentPointer - 1
  3905.         EH_CurrentEntry = EH_Pointer.EH_CurrentPointer
  3906.         call EH_SetRequester
  3907.         EH_DayShowing = EH_EventDay.EH_CurrentEntry
  3908.       end
  3909.     /**/
  3910.  
  3911.     /***//*** EH_NextGad ***/
  3912.       when id == id.EH_next_ then do
  3913.         call EH_ReadSettings
  3914.         EH_CurrentPointer = EH_CurrentPointer + 1
  3915.         EH_CurrentEntry = EH_Pointer.EH_CurrentPointer
  3916.         call EH_SetRequester
  3917.         EH_DayShowing = EH_EventDay.EH_CurrentEntry
  3918.       end
  3919.     /**/
  3920.  
  3921.     /***//*** EH_EventImageGad ***/
  3922.       when id == id.EH_eventimage_ then do
  3923.         EH_Dir = CheckDir(ScriptDir'Images/')
  3924.         if EH_Dir == '' then EH_Dir = ScriptDir
  3925.         EH_DataFile = bguifilereq(EH_Dir, SelectImage$, EH_winID)
  3926.         if (EH_DataFile ~= '') & (exists(EH_DataFile) == 1) then call bguiset(obj.EH_event_, EH_winID, STRINGA_TextVal,EH_DataFile)
  3927.         else do
  3928.           if EH_DataFile ~= '' then call bguireq(EH_DataFile' 'CantFind$'...','*'OK$,'FWCalendar 'Notice$,EH_winID)
  3929.           EH_DataFile = ''
  3930.         end
  3931.       end
  3932.     /**/
  3933.  
  3934.     /***//*** EH_ChangeMontGad ***/
  3935.       when id == id.changemonth_ then do
  3936.         call EH_ReadSettings
  3937.         call EH_SaveHighlightData
  3938.         call bguiwinclose(EH_winID)
  3939.         EH_SelectMonth = bguiget(obj.changemonth_,CYC_Active) + 1
  3940.         call bguiwinclose(EH_winID)
  3941.         EH_Done = 2
  3942.       end
  3943.     /**/
  3944.  
  3945.     /***//*** EH_HighlightTypeGad ***/
  3946.       when id == id.EH_highlighttype_ then do
  3947.         EH_HighlightType = bguiget(obj.EH_highlighttype_,CYC_Active)
  3948.         EH_HighlightType.CurrentEntry = EH_HighlightTypeCyc.EH_HighlightType
  3949.         select
  3950.           when EH_HighlightType.CurrentEntry == 'Fixed' then call EH_SetFixed
  3951.           when EH_HighlightType.CurrentEntry == 'Float' then do
  3952.             call EH_SetFloat
  3953.             call EH_CheckWeekNumber
  3954.           end
  3955.           when EH_HighlightType.CurrentEntry == 'BiOrWeekly' then do
  3956.             call EH_SetBiOrWeekly
  3957.             call EH_CheckWeekType
  3958.           end
  3959.         end
  3960.       end
  3961.     /**/
  3962.  
  3963.     /***//*** EH_WeekNumberGad ***/
  3964.       when id == id.EH_weeknumber_ then do
  3965.         if EH_EventDay.EH_CurrentEntry > 0 then do
  3966.           EH_GadgetID = EH_ButtonID.EH_DayShowing
  3967.           interpret "call bguiset(obj."EH_GadgetID"_,EH_winID, GA_Selected, 0)"
  3968.           EH_EventDay = EH_EventDay.EH_CurrentEntry
  3969.           EH_Weeknumber.EH_CurrentEntry = bguiget(obj.EH_weeknumber_,CYC_Active)
  3970.  
  3971.           do until EH_EventDay < 1
  3972.             EH_EventDay = EH_EventDay - 7
  3973.           end
  3974.           do EH_i = 0 to EH_Weeknumber.EH_CurrentEntry
  3975.             EH_EventDay = EH_EventDay + 7
  3976.           end
  3977.           if EH_EventDay > MonthLength.EH_ShortMonth then EH_EventDay = EH_EventDay - 7
  3978.  
  3979.           EH_GadgetID = EH_ButtonID.EH_EventDay
  3980.           interpret "call bguiset(obj."EH_GadgetID"_,EH_winID, GA_Selected, 1)"
  3981.           EH_EventDay.EH_CurrentEntry = EH_EventDay
  3982.           EH_DayShowing = EH_EventDay
  3983.         end
  3984.       end
  3985.     /**/
  3986.  
  3987.     /***//*** EH_WeekTypeGad ***/
  3988.       when id == id.EH_weektype_ then do
  3989.         if EH_EventDay.EH_CurrentEntry > 0 then do
  3990.           EH_GadgetID = EH_ButtonID.EH_DayShowing
  3991.           interpret "call bguiset(obj."EH_GadgetID"_,EH_winID, GA_Selected, 0)"
  3992.           EH_EventDay = EH_EventDay.EH_CurrentEntry
  3993.           EH_TempWeek = bguiget(obj.EH_weektype_,CYC_Active)
  3994.           if (EH_TempWeek ~= 0) & (EH_Week ~= EH_TempWeek) then do
  3995.             if EH_EventDay - 7 < 1 then EH_EventDay = EH_EventDay + 7
  3996.             else EH_EventDay = EH_EventDay - 7
  3997.           end
  3998.           EH_GadgetID = EH_ButtonID.EH_EventDay
  3999.           interpret "call bguiset(obj."EH_GadgetID"_,EH_winID, GA_Selected, 1)"
  4000.           EH_EventDay.EH_CurrentEntry = EH_EventDay
  4001.           EH_DayShowing = EH_EventDay
  4002.           EH_Week = EH_TempWeek
  4003.         end
  4004.       end
  4005.     /**/
  4006.  
  4007.     /***//*** EH_NewGad ***/
  4008.       when id == id.EH_new_ then do
  4009.         call EH_ReadSettings
  4010.         if EH_DayShowing ~= 0 then do
  4011.           EH_GadgetID = EH_ButtonID.EH_DayShowing
  4012.           interpret "call bguiset(obj."EH_GadgetID"_,EH_winID, GA_Selected, 0)"
  4013.         end
  4014.         EH_EntryCount = EH_EntryCount + 1
  4015.         EH_CurrentPointer = EH_EntryCount
  4016.         EH_HighEntry = EH_HighEntry + 1
  4017.         EH_Pointer.EH_CurrentPointer = EH_HighEntry
  4018.         EH_CurrentEntry = EH_HighEntry
  4019.         call EH_CreateEntry
  4020.         call EH_SetGads
  4021.         call EH_SetRequester
  4022.       end
  4023.     /**/
  4024.  
  4025.     /***//*** EH_DeleteGad ***/
  4026.       when id == id.EH_delete_ then do
  4027.         call EH_ReadSettings
  4028.         if EH_EntryCount == 1 then do
  4029.           EH_CurrentEntry   = 0
  4030.           EH_CurrentPointer = 0
  4031.           EH_EntryCount     = 0
  4032.         end
  4033.         else do
  4034.           do EH_i = EH_CurrentPointer to EH_EntryCount - 1
  4035.             EH_NextPointer = EH_i + 1
  4036.             EH_Pointer.EH_i = EH_Pointer.EH_NextPointer
  4037.           end
  4038.           EH_EntryCount = EH_EntryCount - 1
  4039.           EH_CurrentPointer = min(EH_CurrentPointer, EH_EntryCount)
  4040.           EH_CurrentEntry = EH_Pointer.EH_CurrentPointer
  4041.         end
  4042.         call EH_SetRequester
  4043.         EH_DayShowing = EH_EventDay.EH_CurrentEntry
  4044.       end
  4045.     /**/
  4046.  
  4047.     /***//*** EH_DateButtons ***/
  4048.       when (datatype(EH_Arg.id) == 'NUM') | (EH_Arg.id == 'LD') then do
  4049.         if EH_Arg.id == EH_DayShowing then do
  4050.           /* Re-set current date button */
  4051.           EH_GadgetID = EH_ButtonID.EH_DayShowing
  4052.           interpret "call bguiset(obj."EH_GadgetID"_,EH_winID, GA_Selected, 1)"
  4053.         end
  4054.         else do
  4055.           /* Clear previous date button if necessary */
  4056.           if EH_DayShowing ~= 0 then do
  4057.             EH_GadgetID = EH_ButtonID.EH_DayShowing
  4058.             interpret "call bguiset(obj."EH_GadgetID"_,EH_winID, GA_Selected, 0)"
  4059.           end
  4060.           /* Set current date button */
  4061.           EH_DayShowing = EH_Arg.id
  4062.           EH_GadgetID = EH_ButtonID.EH_DayShowing
  4063.           interpret "call bguiset(obj."EH_GadgetID"_,EH_winID, GA_Selected, 1)"
  4064.           EH_EventDay.EH_CurrentEntry = EH_Arg.id
  4065.  
  4066.           /* Check for impacts of change */
  4067.           if EH_HighlightType.CurrentEntry == 'Float' then call EH_CheckWeekNumber
  4068.           else if EH_HighlightType.CurrentEntry == 'BiOrWeekly' then call EH_CheckWeekType
  4069.         end
  4070.       end
  4071.     /**/
  4072.  
  4073.       otherwise nop
  4074.     end
  4075.   end
  4076.   return EH_Done
  4077.   /**/
  4078.  
  4079. /***//*** EH_CheckWeekNumber  *********/
  4080. EH_CheckWeekNumber:
  4081.   EH_TempDay = EH_EventDay.EH_CurrentEntry
  4082.   EH_Weeknumber.EH_CurrentEntry = 0
  4083.  
  4084.   do until EH_TempDay < 0
  4085.     EH_TempDay = EH_TempDay - 7
  4086.     if EH_TempDay > 0 then EH_Weeknumber.EH_CurrentEntry = EH_Weeknumber.EH_CurrentEntry + 1
  4087.   end
  4088.   call bguiset(obj.EH_weeknumber_, EH_winID, CYC_Active, EH_Weeknumber.EH_CurrentEntry)
  4089.  
  4090.   return
  4091. /**/
  4092.  
  4093. /***//*** EH_CheckWeekType  *********/
  4094. EH_CheckWeekType:
  4095.   interpret 'EH_StartYear = Day.'DateInfo('W', EH_Year'0101', 'S')
  4096.   EH_YearOffset = 7 - EH_StartYear
  4097.   if EH_YearOffset == 7 then EH_YearOffset = 0
  4098.   EH_Week = 2 - (trunc((right(DateInfo('J', EH_Year''EH_Month''right(EH_EventDay.EH_CurrentEntry, 2, '0'), 'S'), 3) - EH_YearOffset - 1)/7 + 1))//2
  4099.   call bguiset(obj.EH_weektype_, EH_winID, CYC_Active, EH_Week)
  4100.   return
  4101. /**/
  4102.  
  4103. /***//*** EH_CreateEntry  *********/
  4104. EH_CreateEntry:
  4105.   EH_Event.EH_CurrentEntry    = ''
  4106.   EH_Comment.EH_CurrentEntry  = ''
  4107.   EH_EventDay.EH_CurrentEntry = 1
  4108.   EH_Holiday.EH_CurrentEntry  = 0
  4109.   EH_Color.EH_CurrentEntry    = ColorList.COUNT
  4110.  
  4111.   if EH_SelectMonth < 14 then do
  4112.     EH_HighlightType.EH_CurrentEntry = 'Fixed'
  4113.     EH_Keyword.EH_CurrentEntry       = 'Highlight'
  4114.     EH_Weekend.EH_CurrentEntry       = 'OK'
  4115.     EH_DayShowing                    = 1
  4116.   end
  4117.  
  4118.   return
  4119. /**/
  4120.  
  4121. /***//*** EH_GhostGads  *********/
  4122. EH_GhostGads:
  4123.   do EH_i = 1 to EH_Button
  4124.     interpret "call bguiset(obj."EH_i"_,EH_winID, GA_Disabled, 1, GA_Selected, 0)"
  4125.   end
  4126.   call bguiset(obj.EH_event_,EH_winID,GA_Disabled, 1)
  4127.   call bguiset(obj.EH_event_, EH_winID, STRINGA_TextVal,'')
  4128.   call bguiset(obj.EH_comment_,EH_winID,GA_Disabled, 1)
  4129.   call bguiset(obj.EH_comment_, EH_winID, STRINGA_TextVal,'')
  4130.   call bguiset(obj.EH_eventimage_,EH_winID,GA_Disabled, 1)
  4131.   call bguiset(obj.EH_highlightcolor_,EH_winID,GA_Disabled, 1)
  4132.   call bguiset(obj.EH_highlighttype_,EH_winID,GA_Disabled, 1)
  4133.   call bguiset(obj.EH_weeknumber_,EH_winID,GA_Disabled, 1)
  4134.   call bguiset(obj.EH_weektype_,EH_winID,GA_Disabled, 1)
  4135.   call bguiset(obj.EH_weekend_,EH_winID,GA_Disabled, 1)
  4136.   call bguiset(obj.EH_holiday_,EH_winID,GA_Disabled, 1)
  4137.   call bguiset(obj.EH_easter_,EH_winID, GA_Disabled, 1)
  4138.   call bguiset(obj.EH_easter_, EH_winID, STRINGA_TextVal,'')
  4139.   call bguiset(obj.EH_delete_,EH_winID, GA_Disabled, 1)
  4140.   return
  4141. /**/
  4142.  
  4143. /***//*** EH_ReadSettings  *********/
  4144. EH_ReadSettings:
  4145.   EH_Event.EH_CurrentEntry = bguiget(obj.EH_event_, STRINGA_TextVal)
  4146.   EH_Comment.EH_CurrentEntry = bguiget(obj.EH_comment_, STRINGA_TextVal)
  4147.   EH_Color.EH_CurrentEntry = bguiget(obj.EH_highlightcolor_, CYC_Active)
  4148.  
  4149.   parse var EH_Event.EH_CurrentEntry EH_Image','EH_X','EH_Y
  4150.   if exists(EH_Image) then EH_Image = 1
  4151.   else EH_Image = 0
  4152.   if EH_SelectMonth < 14 then do
  4153.     EH_HighlightType = bguiget(obj.EH_highlighttype_,CYC_Active)
  4154.     interpret 'EH_HighlightType.EH_CurrentEntry = EH_HighlightTypeCyc.'EH_HighlightType
  4155.     interpret 'EH_Keyword.EH_CurrentEntry = EH_KeywordCode.'EH_HighlightType''EH_Image
  4156.     EH_Weeknumber.EH_CurrentEntry = bguiget(obj.EH_weeknumber_,CYC_Active)
  4157.     interpret 'EH_WeekType.EH_CurrentEntry = EH_WeekTypeCyc.'bguiget(obj.EH_weektype_,CYC_Active)
  4158.     interpret 'EH_Weekend.EH_CurrentEntry = EH_WeekendCyc.'bguiget(obj.EH_weekend_,CYC_Active)
  4159.   end
  4160.   else EH_EventDay.EH_CurrentEntry = bguiget(obj.EH_easter_, STRINGA_TextVal)
  4161.  
  4162.   EH_Holiday.EH_CurrentEntry = bguiget(obj.EH_holiday_, GA_Selected)
  4163.   return
  4164. /**/
  4165.  
  4166. /***//*** EH_SaveHighlightData  *********/
  4167. EH_SaveHighlightData:
  4168.   do EH_i = 1 to EH_EntryCount
  4169.     EH_CurrentPointer = EH_i
  4170.     EH_CurrentEntry   = EH_Pointer.EH_CurrentPointer
  4171.     EH_EventDay = EH_EventDay.EH_CurrentEntry
  4172.  
  4173.     interpret 'EH_Color = ColorList.'EH_Color.EH_CurrentEntry
  4174.     if EH_EventDay == 'LD' then EH_EventDay = 32
  4175.     if pos('"', EH_Event.EH_CurrentEntry) == 0 then EH_QuoteChar = '"'
  4176.     else QuoteChar = "'"
  4177.     if EH_Holiday.EH_CurrentEntry == 128 then EH_Event.EH_CurrentEntry = EH_Event.EH_CurrentEntry'#'
  4178.     if EH_Weekend.EH_CurrentEntry ~= 'OK' then EH_EventDay = EH_EventDay''EH_Weekend.EH_CurrentEntry
  4179.     if (upper(EH_Keyword.EH_CurrentEntry) == 'HIGHLIGHT') | (upper(EH_Keyword.EH_CurrentEntry) == 'IMAGE') then do
  4180.       EH_DataLine = EH_SelectMonth''EH_Keyword.EH_CurrentEntry'.'EH_SelectMonth - 0'.'EH_EventDay' =',
  4181.                     EH_QuoteChar''EH_Event.EH_CurrentEntry''EH_QuoteChar
  4182.       if upper(EH_Keyword.EH_CurrentEntry) == 'HIGHLIGHT' then EH_DataLine = EH_DataLine ' ,'EH_QuoteChar''EH_Color''EH_QuoteChar
  4183.     end
  4184.     else if (upper(EH_Keyword.EH_CurrentEntry) == 'CALCULATEDATE') | (upper(EH_Keyword.EH_CurrentEntry) == 'CALCULATEIMAGE') then do
  4185.       EH_DayOfWeek = DateInfo('W', EH_Year''EH_Month''right(EH_EventDay.EH_CurrentEntry, 2, '0'), 'S')
  4186.  
  4187.       if EH_HighlightType.EH_CurrentEntry == 'Float' then do
  4188.         interpret 'EH_DayNumber = Day.'EH_DayOfWeek
  4189.         if EH_Weeknumber.EH_CurrentEntry < 4 then do
  4190.           EH_DayNumber = EH_DayNumber + 1
  4191.           if EH_DayNumber == 7 then EH_DayNumber = 0
  4192.           interpret 'EH_DayOfWeek = Day.'EH_DayNumber
  4193.           EH_EventDay = 7 * (EH_Weeknumber.EH_CurrentEntry + 1)
  4194.         end
  4195.         else do
  4196.           EH_EventDay = Monthlength.EH_ShortMonth
  4197.           EH_TempDay = Monthlength.EH_ShortMonth - 29
  4198.           EH_DayNumber = EH_DayNumber - EH_TempDay
  4199.           if EH_DayNumber < 0 then EH_DayNumber = EH_DayNumber + 7
  4200.           else if EH_DayNumber > 6 then EH_DayNumber = EH_DayNumber - 7
  4201.           interpret 'EH_DayOfWeek = Day.'EH_DayNumber
  4202.         end
  4203.       end
  4204.       else EH_EventDay = "'"EH_WeekType.EH_CurrentEntry"'"
  4205.  
  4206.       EH_DataLine = EH_SelectMonth''EH_Keyword.EH_CurrentEntry'('EH_SelectMonth - 0',"'EH_DayOfWeek'",'EH_EventDay',',
  4207.                     EH_QuoteChar''EH_Event.EH_CurrentEntry''EH_QuoteChar
  4208.       if upper(EH_Keyword.EH_CurrentEntry) == 'CALCULATEDATE' then EH_DataLine = EH_DataLine ' ,'EH_QuoteChar''EH_Color''EH_QuoteChar
  4209.       EH_DataLine = EH_DataLine')'
  4210.     end
  4211.     else if EH_SelectMonth == 14 then do
  4212.       EH_DataLine = 'CalculateEDate('EH_EventDay.EH_CurrentEntry',',
  4213.                     EH_QuoteChar''EH_Event.EH_CurrentEntry''EH_QuoteChar',',
  4214.                     EH_QuoteChar''EH_Color''EH_QuoteChar')'
  4215.     end
  4216.     if EH_Comment.EH_CurrentEntry ~= '' then EH_DataLine = EH_DataLine'  /* 'EH_Comment.EH_CurrentEntry' */'
  4217.     HighlightData.EH_SelectMonth.EH_i = EH_DataLine
  4218.   end
  4219.   MonthCount.EH_SelectMonth = EH_EntryCount
  4220.   return
  4221. /**/
  4222.  
  4223. /***//*** EH_SetBiOrWeekly  *********/
  4224. EH_SetBiOrWeekly:
  4225.   EH_GadgetID = EH_ButtonID.LD
  4226.   interpret "call bguiset(obj."EH_GadgetID"_,EH_winID, GA_Disabled, 1)"
  4227.   if EH_EventDay.EH_CurrentEntry == 'LD' then do
  4228.     interpret "call bguiset(obj."EH_GadgetID"_,EH_winID, GA_Selected, 0)"
  4229.     EH_EventDay.EH_CurrentEntry = 1
  4230.     EH_GadgetID = EH_ButtonID.1
  4231.     interpret "call bguiset(obj."EH_GadgetID"_,EH_winID, GA_Selected, 1)"
  4232.     EH_DayShowing = 1
  4233.   end
  4234.   call bguiset(obj.EH_weeknumber_,EH_winID,GA_Disabled, 1)
  4235.   call bguiset(obj.EH_weektype_,EH_winID,GA_Disabled, 0)
  4236.   call bguiset(obj.EH_weekend_,EH_winID,GA_Disabled, 1)
  4237.   call bguiset(obj.EH_easter_,EH_winID,GA_Disabled, 1)
  4238.   return
  4239. /**/
  4240.  
  4241. /***//*** EH_SetFixed  *********/
  4242. EH_SetFixed:
  4243.   EH_GadgetID = EH_ButtonID.LD
  4244.   interpret "call bguiset(obj."EH_GadgetID"_,EH_winID, GA_Disabled, 0)"
  4245.   call bguiset(obj.EH_weeknumber_,EH_winID,GA_Disabled, 1)
  4246.   call bguiset(obj.EH_weektype_,EH_winID,GA_Disabled, 1)
  4247.   call bguiset(obj.EH_weekend_,EH_winID,GA_Disabled, 0)
  4248.   call bguiset(obj.EH_easter_,EH_winID,GA_Disabled, 1)
  4249.   return
  4250. /**/
  4251.  
  4252. /***//*** EH_SetFloat  *********/
  4253. EH_SetFloat:
  4254.   EH_GadgetID = EH_ButtonID.LD
  4255.   interpret "call bguiset(obj."EH_GadgetID"_,EH_winID, GA_Disabled, 1)"
  4256.   if EH_EventDay.EH_CurrentEntry == 'LD' then do
  4257.     interpret "call bguiset(obj."EH_GadgetID"_,EH_winID, GA_Selected, 0)"
  4258.     EH_EventDay.EH_CurrentEntry = 1
  4259.     EH_GadgetID = EH_ButtonID.1
  4260.     interpret "call bguiset(obj."EH_GadgetID"_,EH_winID, GA_Selected, 1)"
  4261.     EH_DayShowing = 1
  4262.   end
  4263.   call bguiset(obj.EH_weeknumber_,EH_winID,GA_Disabled, 0)
  4264.   call bguiset(obj.EH_weektype_,EH_winID,GA_Disabled, 1)
  4265.   call bguiset(obj.EH_weekend_,EH_winID,GA_Disabled, 1)
  4266.   call bguiset(obj.EH_easter_,EH_winID,GA_Disabled, 1)
  4267.   return
  4268. /**/
  4269.  
  4270. /***//*** EH_SetGads  *********/
  4271. EH_SetGads:
  4272.   if EH_SelectMonth ~= 14 then do
  4273.     do EH_i = 1 to EH_Button
  4274.       EH_temp = EH_Button.EH_i
  4275.       if EH_Arg.EH_temp ~= 'dummy' then interpret "call bguiset(obj."EH_i"_,EH_winID, GA_Disabled, 0)"
  4276.     end
  4277.     call bguiset(obj.EH_highlighttype_,EH_winID,GA_Disabled, 0)
  4278.     call bguiset(obj.EH_weeknumber_,EH_winID,GA_Disabled, 0)
  4279.     call bguiset(obj.EH_weektype_,EH_winID,GA_Disabled, 0)
  4280.     call bguiset(obj.EH_weekend_,EH_winID,GA_Disabled, 0)
  4281.   end
  4282.   else call bguiset(obj.EH_easter_,EH_winID, GA_Disabled, 0)
  4283.  
  4284.   call bguiset(obj.EH_event_,EH_winID,GA_Disabled, 0)
  4285.   call bguiset(obj.EH_comment_,EH_winID,GA_Disabled, 0)
  4286.   call bguiset(obj.EH_highlightcolor_,EH_winID,GA_Disabled, 0)
  4287.   call bguiset(obj.EH_eventimage_,EH_winID,GA_Disabled, 0)
  4288.   call bguiset(obj.EH_holiday_,EH_winID,GA_Disabled, 0)
  4289.   call bguiset(obj.EH_delete_,EH_winID, GA_Disabled, 0)
  4290.   return
  4291. /**/
  4292.  
  4293. /***//*** EH_SetRequester  *********/
  4294. call EH_SetRequester:
  4295.   /* Set 'Prev' & 'Next' gads */
  4296.   if EH_CurrentPointer < 2 then call bguiset(obj.EH_prev_,EH_winID,GA_Disabled, 1)
  4297.   else call bguiset(obj.EH_prev_,EH_winID,GA_Disabled, 0)
  4298.   if EH_CurrentPointer == EH_EntryCount then call bguiset(obj.EH_next_,EH_winID,GA_Disabled, 1)
  4299.   else call bguiset(obj.EH_next_,EH_winID,GA_Disabled, 0)
  4300.  
  4301.   if EH_EntryCount > 0 then do
  4302.     if EH_SelectMonth < 14 then do
  4303.       /* De-select existing date button */
  4304.       if EH_DayShowing ~= 0 then do
  4305.         EH_GadgetID = EH_ButtonID.EH_DayShowing
  4306.         interpret "call bguiset(obj."EH_GadgetID"_,EH_winID, GA_Selected, 0)"
  4307.       end
  4308.       /* Select current date button */
  4309.       EH_EventDay = EH_EventDay.EH_CurrentEntry
  4310.       EH_GadgetID = EH_ButtonID.EH_EventDay
  4311.       EH_HighlightType = EH_HighlightType.EH_CurrentEntry
  4312.       interpret "call bguiset(obj."EH_GadgetID"_,EH_winID, GA_Selected, 1)"
  4313.  
  4314.       interpret 'call bguiset(obj.EH_highlighttype_,EH_winID,CYC_Active,EH_HighlightTypeCyc.'EH_HighlightType')'
  4315.       interpret 'call EH_Set'EH_HighlightType
  4316.       interpret 'call bguiset(obj.EH_weekend_,EH_winID,CYC_Active,EH_WeekendCyc.'EH_Weekend.EH_CurrentEntry')'
  4317.       call bguiset(obj.EH_holiday_,EH_winID,GA_Selected,EH_Holiday.EH_CurrentEntry)
  4318.       if EH_HighlightType == 'Float' then call EH_CheckWeekNumber
  4319.       else if EH_HighlightType == 'BiOrWeekly' then call EH_CheckWeekType
  4320.     end
  4321.     else call bguiset(obj.EH_easter_, EH_winID, STRINGA_TextVal,EH_EventDay.EH_CurrentEntry)
  4322.  
  4323.     /* Set event & comment */
  4324.     call bguiset(obj.EH_event_, EH_winID, STRINGA_TextVal,EH_Event.EH_CurrentEntry)
  4325.     call bguiset(obj.EH_comment_, EH_winID, STRINGA_TextVal,EH_Comment.EH_CurrentEntry)
  4326.     call bguiset(obj.EH_highlightcolor_,EH_winID,CYC_Active,EH_Color.EH_CurrentEntry)
  4327.   end
  4328.   else call EH_GhostGads
  4329.  
  4330.   return
  4331. /**/
  4332.  
  4333. /**/
  4334.  
  4335. /***//*** EditHighlight_CA (EH) ***/
  4336. EditHighlight_CA:
  4337.   /***//*** Initialize Variables ***/
  4338.   Req = OpenBusy(PrepReq$, 6)
  4339.   EH_DayShowing = 0
  4340.  
  4341.   EH_WeekendCyc.0     = "OK"
  4342.   EH_WeekendCyc.1     = "P"
  4343.   EH_WeekendCyc.2     = "N"
  4344.   EH_WeekendCyc.OK    = 0
  4345.   EH_WeekendCyc.P     = 1
  4346.   EH_WeekendCyc.N     = 2
  4347.  
  4348.   EH_WeekTypeCyc.0    = "All"
  4349.   EH_WeekTypeCyc.1    = "Odd"
  4350.   EH_WeekTypeCyc.2    = "Even"
  4351.   EH_WeekTypeCyc.All  = 0
  4352.   EH_WeekTypeCyc.Odd  = 1
  4353.   EH_WeekTypeCyc.Even = 2
  4354.  
  4355.   EH_HighlightTypeCyc.Fixed      = 0
  4356.   EH_HighlightTypeCyc.Float      = 1
  4357.   EH_HighlightTypeCyc.BiOrWeekly = 2
  4358.   EH_HighlightTypeCyc.Easter     = 3
  4359.   EH_HighlightTypeCyc.0          = 'Fixed'
  4360.   EH_HighlightTypeCyc.1          = 'Float'
  4361.   EH_HighlightTypeCyc.2          = 'BiOrWeekly'
  4362.   EH_HighlightTypeCyc.3          = 'Easter'
  4363.  
  4364.   EH_KeywordCode.00 = 'Highlight'
  4365.   EH_KeywordCode.01 = 'Image'
  4366.   EH_KeywordCode.10 = 'CalculateDate'
  4367.   EH_KeywordCode.11 = 'CalculateImage'
  4368.   EH_KeywordCode.20 = 'CalculateDate'
  4369.   EH_KeywordCode.21 = 'CalculateImage'
  4370.  
  4371.   EH_Year = left(date('S'),4)
  4372.   interpret 'EH_StartYear = Day.'DateInfo('W', EH_Year'0101', 'S')
  4373.   EH_YearOffset = 7 - EH_StartYear
  4374.   if EH_YearOffset == 7 then EH_YearOffset = 0
  4375.  
  4376.   EH_SelectMonth = right(EH_SelectMonth, 2, '0')
  4377. /**/
  4378.  
  4379.   /***//*** GUI Description ***/
  4380.   if UpdateBusy(Req, 1) == -1 then call EH_CACleanup
  4381.   HighlightTypeList = '"'Fixed$'|'Floating$'|'BiOrWeekly$'"'
  4382.   WeekNumberList = '"'First$'|'Second$'|'Third$'|'Fourth$'|'Last$'"'
  4383.   WeekTypeList = '"'All$'|'Odd$'|'Even$'"'
  4384.   WeekendList = '"'OK2$'|'PreviousDay$'|'NextDay$'"'
  4385.   EH_MonthList = strip(MonthList, 'T', '"')'|'All$'|'Easter$'"'
  4386.  
  4387.   call open('EH',"awnpipe:SetupReq/xc")
  4388.   call ToPIPE('EH', '"'EnterEventInfo$'" m cg dg v db a so si cs sq sk h ps="'AppScreen'"')
  4389.  
  4390.   call ToPIPE('EH', 'layout v so si b=0')
  4391.     call ToPIPE('EH', 'layout b=0')
  4392.       call ToPIPE('EH', 'label gt="'Event$':" ua')
  4393.       call AssignID('EH_EventGad', ToPIPE('EH', 'string lj tc chl ref'))
  4394.       call AssignID('EH_ChooseEventGad', ToPIPE('EH', 'button ab=0 weiw=0 weih=0 ref'))
  4395.       call AssignID('EH_ListEventGad', ToPIPE('EH', 'chooser weiw=0 weih=0 ref'))
  4396.       call AssignID('EH_CycleEventGad', ToPIPE('EH', 'button weiw=0 gt=">" ref'))
  4397.     call ToPIPE('EH', 'le')
  4398.  
  4399.     call ToPIPE('EH', 'layout b=0')
  4400.       call ToPIPE('EH', 'label gt="'Comment$':" ua')
  4401.       call AssignID('EH_CommentGad', ToPIPE('EH', 'string lj tc chl ref'))
  4402.     call ToPIPE('EH', 'le')
  4403.   call ToPIPE('EH', 'le')
  4404.  
  4405.   call ToPIPE('EH', 'layout weiw=0 b=0')
  4406.     call ToPIPE('EH', 'layout weiw=0 so v')
  4407.       call ToPIPE('EH', 'layout so b=0')
  4408.         call ToPIPE('EH', 'space')
  4409.         call AssignID('EH_MonthGad', ToPIPE('EH', 'chooser pu weiw=5 maxn=14 cl='EH_Monthlist' ref'))
  4410.         call ToPIPE('EH', 'space')
  4411.       call ToPIPE('EH', 'le')
  4412.  
  4413.       call ToPIPE('EH', 'layout e b=0')
  4414.         call ToPIPE('EH', 'button ro b=0 gt="'left(Day.0, 1)'"')
  4415.         call ToPIPE('EH', 'button ro b=0 gt="'left(Day.1, 1)'"')
  4416.         call ToPIPE('EH', 'button ro b=0 gt="'left(Day.2, 1)'"')
  4417.         call ToPIPE('EH', 'button ro b=0 gt="'left(Day.3, 1)'"')
  4418.         call ToPIPE('EH', 'button ro b=0 gt="'left(Day.4, 1)'"')
  4419.         call ToPIPE('EH', 'button ro b=0 gt="'left(Day.5, 1)'"')
  4420.         call ToPIPE('EH', 'button ro b=0 gt="'left(Day.6, 1)'"')
  4421.       call ToPIPE('EH', 'le')
  4422.  
  4423.       if UpdateBusy(Req, 1) == -1 then call EH_CACleanup
  4424.       GadID.  = ''
  4425.       do EH_Week = 0 to 5
  4426.         call ToPIPE('EH', 'layout e b=0')
  4427.         do EH_WeekDay = 0 to 6
  4428.           EH_Posn = (EH_Week * 7) + EH_WeekDay
  4429.           call AssignID('GadID.'EH_Posn, ToPIPE('EH', 'button pb'))
  4430.         end
  4431.         call ToPIPE('EH', 'le')
  4432.       end
  4433.     call ToPIPE('EH', 'le')
  4434.  
  4435.     if UpdateBusy(Req, 1) == -1 then call EH_CACleanup
  4436.     call ToPIPE('EH', 'layout weiw=0 si so v')
  4437.       call ToPIPE('EH', 'layout weiw=0 si so b=0 v')
  4438.         call ToPIPE('EH', 'label weiw=0 ua gt="'Color$':"')
  4439.         call AssignID('EH_ColorGad', ToPIPE('EH', 'button chl weih=0 ref'))
  4440.         call ToPIPE('EH', 'label weiw=0 gt="'Type$':" ua')
  4441.         call AssignID('EH_HLTypeGad', ToPIPE('EH', 'chooser chl pu weiw=0 maxn=3 cl='HighlightTypeList' ref'))
  4442.         call ToPIPE('EH', 'label weiw=0 gt="'WeekNumber$':" ua')
  4443.         call AssignID('EH_WeekNumberGad', ToPIPE('EH', 'chooser chl pu weiw=0 maxn=5 cl='WeekNumberList' ref'))
  4444.         call ToPIPE('EH', 'label weiw=0 gt="'WeekType$':" ua')
  4445.         call AssignID('EH_WeekTypeGad', ToPIPE('EH', 'chooser chl pu weiw=0 maxn=3 cl='WeekTypeList' ref'))
  4446.         call ToPIPE('EH', 'label weiw=0 gt="'Weekend$':" ua')
  4447.         call AssignID('EH_WeekendGad', ToPIPE('EH', 'chooser chl pu weiw=0 maxn=3 cl='WeekendList' ref'))
  4448.         call ToPIPE('EH', 'label weiw=0 gt="'Holiday$':" ua')
  4449.         call AssignID('EH_HolidayGad', ToPIPE('EH', 'checkbox weiw=0 chl ref'))
  4450.         call ToPIPE('EH', 'label weiw=0 gt="'Easter$':" ua')
  4451.         call AssignID('EH_EasterGad', ToPIPE('EH', 'integer a tc minn=-366 maxn=366 weiw=0 lj chl ref'))
  4452.       call ToPIPE('EH', 'le')
  4453.       call ToPIPE('EH', 'layout v si e cj b=0')
  4454.         call ToPIPE('EH', 'layout si e weiw=0 b=0')
  4455.           call AssignID('EH_AddEventGad', ToPIPE('EH', 'button weiw=0 weih=0 gt="'AddEvent$'" ref'))
  4456.           call AssignID('EH_DeleteEventGad', ToPIPE('EH', 'button weiw=0 weih=0 gt="'DeleteEvent$'" ref'))
  4457.         call ToPIPE('EH', 'le')
  4458.         call AssignID('EH_DoneGad', ToPIPE('EH', 'button weih=0 weiw=0 gt="'Done$'" c ref'))
  4459.       call ToPIPE('EH', 'le')
  4460.     call ToPIPE('EH', 'le')
  4461.   call ToPIPE('EH', 'le')
  4462.  
  4463.   GetEHFileGad = ToPIPE('EH', 'getfile ua pat="#?"')
  4464.  
  4465.   GadText.EH_CycleEventGad.0 = '>'
  4466.   GadText.EH_CycleEventGad.1 = '<'
  4467. /**/
  4468.  
  4469.   /***//*** GUI Action Loop ***/
  4470.   call ToPIPE('EH', 'open')
  4471.  
  4472.   if UpdateBusy(Req, 1) == -1 then call EH_CACleanup
  4473.  
  4474.   call EH_CASetRequester
  4475.   call CloseBusy('ProgReq')
  4476.  
  4477.   EH_Done = 0
  4478.   do until eof('EH')
  4479.     call ToPIPE('EH', 'continue')
  4480.     EH_EventInfo = readln('EH')
  4481.     parse var EH_EventInfo EH_Event' 'EH_GadID' 'EH_GadInfo1
  4482.     select
  4483.     /***//*** Close ***/
  4484.       when EH_Event == 'close' then do
  4485.         if EH_GadID == EH_DoneGad then call EH_CASaveHighlightData
  4486.         EH_Done = 1
  4487.       end
  4488.     /**/
  4489.  
  4490.     /***//*** Help ***/
  4491.       when EH_Event == 'help' then do
  4492.         if EH_GadID ~= -1 then do
  4493.           OverGad = EH_GadID
  4494.           if (EH_GadID ~= ShiftedGad) & (ShiftedGad > 0) then do
  4495.             call ToPIPE('EH', 'id 'ShiftedGad' gt="'GadText.ShiftedGad.0'"')
  4496.             ShiftedGad = 0
  4497.           end
  4498.           if (ShiftDown == 1) & (symbol('GadText.OverGad.1') == 'VAR') then do
  4499.             call ToPIPE('EH', 'id 'OverGad' gt="'GadText.OverGad.1'"')
  4500.             ShiftedGad = OverGad
  4501.           end
  4502.         end
  4503.       end
  4504.     /**/
  4505.  
  4506.     /***//*** Qualifers ***/
  4507.       when EH_Event == 'qual' then do
  4508.         ShiftDown = (EH_GadID == 1)|(EH_GadID == 2)
  4509.         if (ShiftDown == 0) & (ShiftedGad > 0) then do
  4510.           call ToPIPE('EH', 'id 'ShiftedGad' gt="'GadText.OverGad.0'"')
  4511.           ShiftedGad = 0
  4512.         end
  4513.         if (ShiftDown == 1) & (symbol('GadText.OverGad.1') == 'VAR') then do
  4514.           call ToPIPE('EH', 'id 'OverGad' gt="'GadText.OverGad.1'"')
  4515.           ShiftedGad = OverGad
  4516.         end
  4517.       end
  4518.     /**/
  4519.  
  4520.     /***//*** Key event ***/
  4521.       when EH_Event == 'key' then do
  4522.         HelpGad = DSR_Help.OverGad
  4523.         interpret 'HelpText = Help$.'HelpGad
  4524.         if EH_Day.OverGad == 'LD' then HelpText = Help$.LD
  4525.         if (EH_GadID == 95) & (symbol('Help$.'HelpGad) == 'VAR') then
  4526.           call CASimpleReq(Help$, HelpText, HelpTime)
  4527.       end
  4528.     /**/
  4529.  
  4530.     /***//*** EH_EventGad ***/
  4531.       when EH_GadID == EH_EventGad then call EH_CAProcessEventGad(EH_GadInfo1)
  4532.     /**/
  4533.  
  4534.     /***//*** EH_ChooseEventGad ***/
  4535.       when EH_GadID == EH_ChooseEventGad then do
  4536.         address command 'assign >NIL: FWC: 'ScriptDir'Images/'
  4537.         if RC == 20 then EH_Dir = ScriptDir
  4538.         else do
  4539.           EH_Dir = ScriptDir'Images/'
  4540.           address command 'assign >NIL: FWC:'
  4541.         end
  4542.         EH_DataFile = CAGetFile('EH', GetEHFileGad, SelectImage$, EH_Dir)
  4543.         if EH_DataFile ~= '' then do
  4544.           if exists(EH_DataFile) then do
  4545.             EH_Event.EH_CurrentEntry = EH_DataFile
  4546.             EH_Image.EH_CurrentEntry = 1
  4547.             call ToPIPE('EH', 'id 'EH_EventGad' gt="'EH_DataFile'"')
  4548.           end
  4549.           else do
  4550.             call ToPIPE('EH', 'id 0 s=256')
  4551.             call CASimpleReq('FWCalendar 'Notice$, EH_DataFile' 'CantFind$'...')
  4552.             call ToPIPE('EH', 'id 0 s=512')
  4553.           end
  4554.         end
  4555.         call EH_CAUpdateEventList
  4556.       end
  4557.     /**/
  4558.  
  4559.     /***//*** EH_ListEventGad ***/
  4560.       when EH_GadID == EH_ListEventGad then do
  4561.         EH_Comment.EH_CurrentEntry = ReadCAGad('EH', EH_CommentGad)
  4562.         call EH_CAProcessEventGad(ReadCAGad('EH', EH_EventGad))
  4563.         EH_CurrentPointer = EH_GadInfo1 + 1
  4564.         EH_CurrentEntry = EH_Pointer.EH_CurrentPointer
  4565.         call EH_CASetEvent
  4566.       end
  4567.    /**/
  4568.  
  4569.     /***//*** EH_CycleEventGad ***/
  4570.       when EH_GadID == EH_CycleEventGad then do
  4571.         EH_Comment.EH_CurrentEntry = ReadCAGad('EH', EH_CommentGad)
  4572.         call EH_CAProcessEventGad(ReadCAGad('EH', EH_EventGad))
  4573.         if ShiftDown == 1 then do
  4574.           EH_CurrentPointer = EH_CurrentPointer - 1
  4575.           if EH_CurrentPointer == 0 then EH_CurrentPointer = EH_EntryCount
  4576.           EH_CurrentEntry = EH_Pointer.EH_CurrentPointer
  4577.         end
  4578.         else do
  4579.           EH_CurrentPointer = EH_CurrentPointer + 1
  4580.           if EH_CurrentPointer > EH_EntryCount then EH_CurrentPointer = 1
  4581.           EH_CurrentEntry = EH_Pointer.EH_CurrentPointer
  4582.         end
  4583.         call EH_CASetEvent
  4584.       end
  4585.     /**/
  4586.  
  4587.     /***//*** EH_CommentGad ***/
  4588.       when EH_GadID == EH_CommentGad then EH_Comment.EH_CurrentEntry = EH_GadInfo1
  4589.     /**/
  4590.  
  4591.     /***//*** EH_MonthGad ***/
  4592.       when EH_GadID == EH_MonthGad then do
  4593.         EH_Comment.EH_CurrentEntry = ReadCAGad('EH', EH_CommentGad)
  4594.         call EH_CAProcessEventGad(ReadCAGad('EH', EH_EventGad))
  4595.         call EH_CASaveHighlightData
  4596.         EH_SelectMonth = right(EH_GadInfo1 + 1, 2, '0')
  4597.         call EH_CASetRequester
  4598.       end
  4599.     /**/
  4600.  
  4601.     /***//*** EH_ColorGad ***/
  4602.       when EH_GadID == EH_ColorGad then do
  4603.         call ToPIPE('EH', 'id 0 s=256')
  4604.         EH_Color.EH_CurrentEntry = ReadBrowserList('ColorReq', 'ColorGad', 'ColorList')
  4605.         call ToPIPE('EH', 'id 'EH_ColorGad' gt="'EH_Color.EH_CurrentEntry'"')
  4606.         call ToPIPE('EH', 'id 0 s=512')
  4607.       end
  4608.     /**/
  4609.  
  4610.     /***//*** EH_HLTypeGad ***/
  4611.       when EH_GadID == EH_HLTypeGad then do
  4612.         EH_HighlightType.EH_CurrentEntry = EH_GadInfo1
  4613.         select
  4614.           when EH_HighlightTypeCyc.EH_GadInfo1 == 'Fixed' then call EH_CASetFixedGads
  4615.           when EH_HighlightTypeCyc.EH_GadInfo1 == 'Float' then do
  4616.             call EH_CASetFloatGads
  4617.             call EH_CACheckWeekNumber
  4618.           end
  4619.           when EH_HighlightTypeCyc.EH_GadInfo1 == 'BiOrWeekly' then do
  4620.             call EH_CASetBiOrWeeklyGads
  4621.             call EH_CACheckWeekType
  4622.           end
  4623.         end
  4624.       end
  4625.     /**/
  4626.  
  4627.     /***//*** EH_WeekNumberGad ***/
  4628.       when EH_GadID == EH_WeekNumberGad then do
  4629.         EH_Weeknumber.EH_CurrentEntry = EH_GadInfo1
  4630.         if EH_EventDay.EH_CurrentEntry > 0 then do
  4631.           call ToPIPE('EH', 'id 'EH_ButtonID.EH_DayShowing' s=0 ref')
  4632.           EH_EventDay = EH_EventDay.EH_CurrentEntry
  4633.  
  4634.           do until EH_EventDay < 1
  4635.             EH_EventDay = EH_EventDay - 7
  4636.           end
  4637.           do EH_i = 0 to EH_Weeknumber.EH_CurrentEntry
  4638.             EH_EventDay = EH_EventDay + 7
  4639.           end
  4640.           if EH_EventDay > MonthLength.EH_ShortMonth then EH_EventDay = EH_EventDay - 7
  4641.  
  4642.           call ToPIPE('EH', 'id 'EH_ButtonID.EH_EventDay' s=1')
  4643.           EH_EventDay.EH_CurrentEntry = EH_EventDay
  4644.           EH_DayShowing = EH_EventDay
  4645.         end
  4646.       end
  4647.     /**/
  4648.  
  4649.     /***//*** EH_WeekTypeGad ***/
  4650.       when EH_GadID == EH_WeekTypeGad then do
  4651.         EH_WeekType.EH_CurrentEntry = EH_GadInfo1
  4652.         if EH_EventDay.EH_CurrentEntry > 0 then do
  4653.           call ToPIPE('EH', 'id 'EH_ButtonID.EH_DayShowing' s=0 ref')
  4654.           EH_EventDay = EH_EventDay.EH_CurrentEntry
  4655.           if (EH_WeekType.EH_CurrentEntry ~= 0) & (EH_TempWeekType.EH_CurrentEntry ~= EH_WeekType.EH_CurrentEntry) then do
  4656.             if EH_EventDay - 7 < 1 then EH_EventDay = EH_EventDay + 7
  4657.             else EH_EventDay = EH_EventDay - 7
  4658.           end
  4659.           call ToPIPE('EH', 'id 'EH_ButtonID.EH_EventDay' s=1')
  4660.           EH_EventDay.EH_CurrentEntry = EH_EventDay
  4661.           EH_DayShowing = EH_EventDay
  4662.           EH_TempWeekType.EH_CurrentEntry = EH_WeekType.EH_CurrentEntry
  4663.         end
  4664.       end
  4665.     /**/
  4666.  
  4667.     /***//*** EH_WeekendGad ***/
  4668.       when EH_GadID == EH_WeekendGad then EH_Weekend.EH_CurrentEntry = EH_GadInfo1
  4669.     /**/
  4670.  
  4671.     /***//*** EH_HolidayGad ***/
  4672.       when EH_GadID == EH_HolidayGad then EH_Holiday.EH_CurrentEntry = EH_GadInfo1
  4673.     /**/
  4674.  
  4675.     /***//*** EH_EasterGad ***/
  4676.       when EH_GadID == EH_EasterGad then do
  4677.         EH_Easter.EH_CurrentEntry = EH_GadInfo1
  4678.         EH_EventDay.EH_CurrentEntry = EH_GadInfo1
  4679.         call EH_CASortAndFind(EH_CurrentEntry)
  4680.       end
  4681.     /**/
  4682.  
  4683.     /***//*** EH_AddEventGad ***/
  4684.       when EH_GadID == EH_AddEventGad then do
  4685.         EH_Comment.EH_CurrentEntry = ReadCAGad('EH', EH_CommentGad)
  4686.         call EH_CAProcessEventGad(ReadCAGad('EH', EH_EventGad))
  4687.         if EH_EntryCount == 0 then call EH_CASetMonthGads
  4688.         if EH_DayShowing ~= 0 then call ToPIPE('EH', 'id 'EH_ButtonID.EH_DayShowing' s=0 ref')
  4689.         EH_EntryCount = EH_EntryCount + 1
  4690.         EH_CurrentEntry = EH_EntryCount
  4691.  
  4692.         EH_Event.EH_CurrentEntry    = ''
  4693.         EH_Comment.EH_CurrentEntry  = ''
  4694.         EH_EventDay.EH_CurrentEntry = 1
  4695.         EH_Holiday.EH_CurrentEntry  = 0
  4696.         EH_Color.EH_CurrentEntry    = '<'Clear$'>'
  4697.  
  4698.         if EH_SelectMonth < 14 then do
  4699.           EH_HighlightType.EH_CurrentEntry = 0
  4700.           EH_Keyword.EH_CurrentEntry       = 'Highlight'
  4701.           EH_Weekend.EH_CurrentEntry       = 0
  4702.         end
  4703.  
  4704.         call EH_CASortAndFind(EH_CurrentEntry)
  4705.         call EH_CASetEvent
  4706.       end
  4707.     /**/
  4708.  
  4709.     /***//*** EH_DeleteEventGad ***/
  4710.       when EH_GadID == EH_DeleteEventGad then do
  4711.         if EH_EntryCount == 1 then do
  4712.           EH_CurrentEntry   = 0
  4713.           EH_CurrentPointer = 0
  4714.           EH_EntryCount     = 0
  4715.           call EH_CAGhostGads
  4716.         end
  4717.         else do
  4718.           SortFile = ''
  4719.           do EH_i = 1 to EH_EntryCount
  4720.             if EH_i ~= EH_CurrentEntry then SortFile = SortFile''right(EH_i, 3, "0")' 'EH_EventDay.EH_i||'0a'x
  4721.           end
  4722.           call writefile('pipe:FWC', strip(SortFile, 'B', '0a'x))
  4723.           address command 'sort pipe:FWC Pipe:FWC1 Colstart 5 numeric'
  4724.  
  4725.           if EH_CurrentPointer == EH_EntryCount then EH_CurrentPointer = EH_CurrentPointer - 1
  4726.           else EH_CurrentPointer = EH_CurrentPointer + 1
  4727.           EH_CurrentEntry = EH_Pointer.EH_CurrentPointer
  4728.  
  4729.           EH_EntryCount = EH_EntryCount - 1
  4730.           SortedFile = ReadFile('pipe:FWC1')
  4731.           call openv('SortedFile')
  4732.           do EH_i = 1 to EH_EntryCount
  4733.             EH_Pointer.EH_i = left(readvln('SortedFile'), 3) - 0
  4734.             if EH_Pointer.EH_i == EH_CurrentEntry then EH_CurrentPointer = EH_i
  4735.           end
  4736.           call closev('SortedFile')
  4737.           call EH_CAUpdateEventList
  4738.           call EH_CASetEvent
  4739.         end
  4740.         call EH_CASetPrevAndNext
  4741.       end
  4742.     /**/
  4743.  
  4744.     /***//*** Date gadgets ***/
  4745.       otherwise do
  4746.         if symbol('EH_Day.EH_GadID') == 'VAR' then do
  4747.           EH_EventDay.EH_CurrentEntry = EH_Day.EH_GadID
  4748.           if EH_EventDay.EH_CurrentEntry == EH_DayShowing then call ToPIPE('EH', 'id 'EH_ButtonID.EH_DayShowing' s=1')
  4749.           else do
  4750.             /* Clear previous date button if necessary */
  4751.             if EH_DayShowing ~= 0 then call ToPIPE('EH', 'id 'EH_ButtonID.EH_DayShowing' s=0 ref')
  4752.             /* Set current date button */
  4753.             EH_DayShowing = EH_EventDay.EH_CurrentEntry
  4754.             call ToPIPE('EH', 'id 'EH_ButtonID.EH_DayShowing' s=1')
  4755.             /* Check for impacts of change */
  4756.             if EH_HighlightType.EH_CurrentEntry == EH_HighlightTypeCyc.Float then call EH_CACheckWeekNumber
  4757.             else if EH_HighlightType.EH_CurrentEntry == EH_HighlightTypeCyc.BiOrWeekly then call EH_CACheckWeekType
  4758.             call EH_CASortAndFind(EH_CurrentEntry)
  4759.           end
  4760.         end
  4761.       end
  4762.     /**/
  4763.  
  4764.     end
  4765.     if EH_Done ~= 0 then leave
  4766.     if (EH_Event = 'gadget') & (ShiftDown = 1) & (symbol('GadText.EH_GadID.1') == 'VAR') then do
  4767.       ShiftedGad = EH_GadID
  4768.       OverGad = EH_GadID
  4769.       call ToPIPE('EH', 'id 'ShiftedGad' gt="'GadText.ShiftedGad.1'"')
  4770.     end
  4771.   end
  4772.  
  4773.   OverGad       = 0
  4774.   ShiftDown     = 0
  4775.   ShiftedGad    = 0
  4776.   call close('EH')
  4777.   return
  4778. /**/
  4779.  
  4780. /***//*** EH_CACheckWeekNumber ***/
  4781. EH_CACheckWeekNumber:
  4782.   EH_TempDay = EH_EventDay.EH_CurrentEntry
  4783.   EH_Weeknumber.EH_CurrentEntry = 0
  4784.  
  4785.   do until EH_TempDay < 0
  4786.     EH_TempDay = EH_TempDay - 7
  4787.     if EH_TempDay > 0 then EH_Weeknumber.EH_CurrentEntry = EH_Weeknumber.EH_CurrentEntry + 1
  4788.   end
  4789.   call ToPIPE('EH', 'id 'EH_WeekNumberGad' s='EH_Weeknumber.EH_CurrentEntry)
  4790.  
  4791.   return
  4792. /**/
  4793.  
  4794. /***//*** EH_CACheckWeekType ***/
  4795. EH_CACheckWeekType:
  4796.   interpret 'EH_StartYear = Day.'DateInfo('W', EH_Year'0101', 'S')
  4797.   EH_YearOffset = 7 - EH_StartYear
  4798.   if EH_YearOffset == 7 then EH_YearOffset = 0
  4799.   EH_Week = 2 - (trunc((right(DateInfo('J', EH_Year''EH_Month''right(EH_EventDay.EH_CurrentEntry, 2, '0'), 'S'), 3) - EH_YearOffset - 1)/7 + 1))//2
  4800.   call ToPIPE('EH', 'id 'EH_WeekTypeGad' s='EH_Week)
  4801.   return
  4802. /**/
  4803.  
  4804. /***//*** EH_CACleanup ***/
  4805. EH_CACleanup:
  4806.   call CloseBusy('ProgReq')
  4807.   call close('EH')
  4808.   return
  4809. /**/
  4810.  
  4811. /***//*** EH_CAGhostGads ***/
  4812. EH_CAGhostGads:
  4813.   do EH_Posn = 0 to 41
  4814.     call ToPIPE('EH', 'id 'GadID.EH_Posn' s=0 dis=1')
  4815.   end
  4816.   call ToPIPE('EH', 'id 'EH_EventGad' gt="" dis=1 ref')
  4817.   call ToPIPE('EH', 'id 'EH_ChooseEventGad' dis=1 ref')
  4818.   call ToPIPE('EH', 'id 'EH_ListEventGad' dis=1')
  4819.   call ToPIPE('EH', 'id 'EH_CycleEventGad' dis=1')
  4820.   call ToPIPE('EH', 'id 'EH_CommentGad' gt="" dis=1')
  4821.   call ToPIPE('EH', 'id 'EH_ColorGad' dis=1')
  4822.   call ToPIPE('EH', 'id 'EH_HLTypeGad' dis=1')
  4823.   call ToPIPE('EH', 'id 'EH_WeekNumberGad' dis=1')
  4824.   call ToPIPE('EH', 'id 'EH_WeekTypeGad' dis=1')
  4825.   call ToPIPE('EH', 'id 'EH_WeekendGad' dis=1')
  4826.   call ToPIPE('EH', 'id 'EH_HolidayGad' dis=1 ref')
  4827.   call ToPIPE('EH', 'id 'EH_EasterGad' dis=1 ref')
  4828.   call ToPIPE('EH', 'id 'EH_DeleteEventGad' dis=1')
  4829.   return
  4830. /**/
  4831.  
  4832. /***//*** EH_CAProcessEventGad ***/
  4833. EH_CAProcessEventGad:
  4834.   parse arg Value
  4835.   EH_Event.EH_CurrentEntry = Value
  4836.   parse var EH_Event.EH_CurrentEntry EH_Image','EH_X.EH_CurrentEntry','EH_Y.EH_CurrentEntry
  4837.   if exists(EH_Image) then EH_Image.EH_CurrentEntry = 1
  4838.   else EH_Image.EH_CurrentEntry = 0
  4839.   call EH_CAUpdateEventList
  4840.  
  4841.   return
  4842. /**/
  4843.  
  4844. /***//*** EH_CAReadData ***/
  4845. EH_CAReadData:
  4846.   EH_EntryCount = 0
  4847.   OverGad       = 0
  4848.   ShiftDown     = 0
  4849.   ShiftedGad    = 0
  4850.  
  4851.   EH_MonthCount = MonthCount.EH_SelectMonth
  4852.   if EH_MonthCount > 0 then do
  4853.     do EH_j = 1 to EH_MonthCount
  4854.       EH_EntryCount = EH_EntryCount + 1
  4855.       if EH_SelectMonth < 14 then CurrentData.EH_SelectMonth.EH_j = substr(HighlightData.EH_SelectMonth.EH_j, 3)
  4856.       else CurrentData.EH_SelectMonth.EH_j = HighlightData.EH_SelectMonth.EH_j
  4857.       if symbol('CurrentData.EH_SelectMonth.EH_j') == 'VAR' then do
  4858.         EH_HighlightData = strip(CurrentData.EH_SelectMonth.EH_j)
  4859.         if right(EH_HighlightData, 2) == '*/' then do
  4860.           EH_StartComment = lastpos('/*', EH_HighlightData)
  4861.           EH_Comment.EH_EntryCount = strip(substr(EH_HighlightData, EH_StartComment), 'B', ' /*')
  4862.           EH_HighlightData = strip(left(EH_HighlightData, EH_StartComment - 1))
  4863.         end
  4864.         else EH_Comment.EH_EntryCount = ''
  4865.  
  4866.         EH_Keyword = word(EH_HighlightData, 1)
  4867.         EH_FirstDot = pos('.', EH_Keyword)
  4868.         EH_FirstParen = pos('(', EH_Keyword)
  4869.         if EH_FirstDot == 0 then EH_EndOfKeyword = EH_FirstParen
  4870.         else if EH_FirstParen == 0 then EH_EndOfKeyword = EH_FirstDot
  4871.         else EH_EndOfKeyword = min(pos('.', EH_Keyword), pos('(', EH_Keyword))
  4872.         EH_Keyword.EH_EntryCount = left(EH_Keyword, EH_EndOfKeyword - 1)
  4873.         if pos('IMAGE', upper(EH_Keyword.EH_EntryCount)) ~= 0 then EH_Image.EH_EntryCount = 1
  4874.         else EH_Image.EH_EntryCount = 0
  4875.  
  4876.         if (upper(EH_Keyword.EH_EntryCount) == 'HIGHLIGHT') | (upper(EH_Keyword.EH_EntryCount) == 'IMAGE') then do
  4877.           EH_HighlightType.EH_EntryCount = EH_HighlightTypeCyc.Fixed
  4878.           EH_EventDay.EH_EntryCount = substr(EH_Keyword, lastpos('.', EH_Keyword) + 1)
  4879.           EH_Event.EH_EntryCount = substr(EH_HighlightData, pos('=', EH_HighlightData) + 1)
  4880.           parse var EH_Event.EH_EntryCount EH_Event.EH_EntryCount','EH_Color.EH_EntryCount
  4881.           if upper(EH_Keyword.EH_EntryCount) == 'IMAGE' then do
  4882.             if (pos(':', EH_Event.EH_EntryCount) == 0) & (pos('/', EH_Event.EH_EntryCount) == 0) then
  4883.               EH_Event.EH_EntryCount = ScriptDir'Images/'strip(EH_Event.EH_EntryCount, 'B', ' "'||"'")
  4884.           end
  4885.         end
  4886.         else do
  4887.           EH_HighlightData = strip(substr(EH_HighlightData, EH_EndOfKeyword + 1), 'B', ')')
  4888.           if EH_SelectMonth == 14 then do
  4889.             parse var EH_HighlightData EH_EventDay.EH_EntryCount','EH_Event.EH_EntryCount','EH_Color.EH_EntryCount
  4890.             EH_EventDay.EH_EntryCount = strip(EH_EventDay.EH_EntryCount)
  4891.             EH_Easter.EH_EntryCount = EH_EventDay.EH_EntryCount
  4892.             EH_Event.EH_EntryCount = strip(EH_Event.EH_EntryCount)
  4893.             EH_HighlightType.EH_EntryCount = EH_HighlightTypeCyc.Easter
  4894.             EH_Keyword.EH_EntryCount = 'CalculateEDate'
  4895.           end
  4896.           else do
  4897.             parse var EH_HighlightData .','EH_DayOfWeek','EH_HighDate','EH_Event.EH_EntryCount','EH_Color.EH_EntryCount
  4898.             interpret "EH_DayOfWeek = Day."strip(EH_DayOfWeek, 'B', ' "'||"'")
  4899.             EH_HighDate = strip(EH_HighDate)
  4900.             EH_Event.EH_EntryCount = strip(EH_Event.EH_EntryCount)
  4901.             if pos('IMAGE', upper(EH_Keyword.EH_EntryCount)) > 0 then do
  4902.               if (pos(':', EH_Event.EH_EntryCount) == 0) & (pos('/', EH_Event.EH_EntryCount) == 0) then do
  4903.                 EH_Event.EH_EntryCount = ScriptDir'Images/'strip(EH_Event.EH_EntryCount, 'B', ' "'||"'")
  4904.               end
  4905.             end
  4906.             if datatype(EH_HighDate) == 'CHAR' then do
  4907.               /* Weekly/Biweekly events */
  4908.               EH_HighDate = upper(strip(EH_HighDate, 'B', "'"))
  4909.               EH_HighlightType.EH_EntryCount = EH_HighlightTypeCyc.BiOrWeekly
  4910.               interpret 'EH_WeekType.EH_EntryCount = EH_WeekTypeCyc.'EH_HighDate
  4911.               EH_EventOffset = EH_DayOfWeek - EH_StartDate
  4912.               EH_EventDay.EH_EntryCount = 1 + EH_EventOffset
  4913.               if EH_EventDay.EH_EntryCount < 1 then EH_EventDay.EH_EntryCount = EH_EventDay.EH_EntryCount + 7
  4914.               EH_WN = trunc((right(DateInfo('J', EH_Year''EH_Month''right(EH_EventDay.EH_EntryCount, 2, '0'), 'S'), 3) - EH_YearOffset - 1)/7 + 1)
  4915.               if ((EH_HighDate == 'EVEN') & (EH_WN//2 == 1)) | ((EH_HighDate == 'ODD') & (EH_WN//2 == 0)) then EH_EventDay.EH_EntryCount = EH_EventDay.EH_EntryCount + 7
  4916.             end
  4917.             else do
  4918.               EH_HighlightType.EH_EntryCount = EH_HighlightTypeCyc.Float
  4919.               interpret 'EH_First = Day.'DateInfo('W', EH_Year''EH_Month'01', 'S')
  4920.               EH_EventDay.EH_EntryCount = EH_HighDate + (EH_DayOfWeek - EH_First)
  4921.               if EH_First < EH_DayOfWeek then EH_EventDay.EH_EntryCount = EH_EventDay.EH_EntryCount - 7
  4922.               EH_TempDay = EH_EventDay.EH_EntryCount
  4923.               EH_Weeknumber.EH_EntryCount = 0
  4924.               if EH_HighDate > 28 then EH_Weeknumber.EH_EntryCount = 4
  4925.               else do
  4926.                 do until EH_TempDay < 0
  4927.                   EH_TempDay = EH_TempDay - 7
  4928.                   if EH_TempDay > 0 then EH_Weeknumber.EH_EntryCount = EH_Weeknumber.EH_EntryCount + 1
  4929.                 end
  4930.               end
  4931.             end
  4932.           end
  4933.         end
  4934.  
  4935.         if datatype(EH_EventDay.EH_EntryCount) == 'CHAR' then do
  4936.           interpret 'EH_Weekend.EH_EntryCount = EH_WeekendCyc.'upper(right(EH_EventDay.EH_EntryCount, 1))
  4937.           EH_EventDay.EH_EntryCount = left(EH_EventDay.EH_EntryCount, length(EH_EventDay.EH_EntryCount) - 1)
  4938.         end
  4939.         else EH_Weekend.EH_EntryCount = EH_WeekendCyc.OK
  4940.  
  4941.         if EH_EventDay.EH_EntryCount == '32' then EH_EventDay.EH_EntryCount = 'LD'
  4942.  
  4943.         EH_Event.EH_EntryCount = strip(EH_Event.EH_EntryCount, 'B', ' "'||"'")
  4944.         if right(EH_Event.EH_EntryCount, 1) == '#' then do
  4945.           EH_Holiday.EH_EntryCount = 128
  4946.           EH_Event.EH_EntryCount = left(EH_Event.EH_EntryCount, length(EH_Event.EH_EntryCount) - 1)
  4947.         end
  4948.         else EH_Holiday.EH_EntryCount = 0
  4949.       end
  4950.       EH_Color.EH_EntryCount = strip(EH_Color.EH_EntryCount, 'B', ' "'||"'")
  4951.       if EH_Color.EH_EntryCount == '' then EH_Color.EH_EntryCount = '<'Clear$'>'
  4952.     end
  4953.  
  4954.     call EH_CASortAndFind(1)
  4955.   end
  4956.  
  4957.   EH_HighEntry = EH_EntryCount
  4958.   if EH_EntryCount > 0 then do
  4959.     EH_CurrentPointer = 1
  4960.     EH_CurrentEntry = EH_Pointer.EH_CurrentPointer
  4961.   end
  4962.   else do
  4963.     EH_CurrentEntry = 0
  4964.     EH_CurrentPointer = 0
  4965.   end
  4966.  
  4967.   return
  4968. /**/
  4969.  
  4970. /***//*** EH_CASaveHighlightData ***/
  4971. EH_CASaveHighlightData:
  4972.   EH_Comment.EH_CurrentEntry = ReadCAGad('EH', EH_CommentGad)
  4973.   call EH_CAProcessEventGad(ReadCAGad('EH', EH_EventGad))
  4974.   do EH_i = 1 to EH_EntryCount
  4975.     EH_CurrentPointer     = EH_i
  4976.     EH_CurrentEntry       = EH_Pointer.EH_CurrentPointer
  4977.     EH_EventDay           = EH_EventDay.EH_CurrentEntry
  4978.     EH_Weekend            = EH_Weekend.EH_CurrentEntry
  4979.     EH_HighlightType      = EH_HighlightType.EH_CurrentEntry
  4980.     interpret 'EH_Keyword = EH_KeywordCode.'EH_HighlightType.EH_CurrentEntry''EH_Image.EH_CurrentEntry
  4981.  
  4982.     if EH_EventDay == 'LD' then EH_EventDay = 32
  4983.     if EH_Holiday.EH_CurrentEntry == 1 then EH_Event.EH_CurrentEntry = EH_Event.EH_CurrentEntry'#'
  4984.     if EH_WeekendCyc.EH_Weekend ~= 'OK' then EH_EventDay = EH_EventDay''EH_WeekendCYC.EH_Weekend
  4985.     if (upper(EH_Keyword) == 'HIGHLIGHT') | (upper(EH_Keyword) == 'IMAGE') then do
  4986.       EH_DataLine = EH_SelectMonth''EH_Keyword'.'EH_SelectMonth - 0'.'EH_EventDay' = 'QuoteIt(EH_Event.EH_CurrentEntry)
  4987.       if upper(EH_Keyword) == 'HIGHLIGHT' then EH_DataLine = EH_DataLine', 'QuoteIt(EH_Color.EH_CurrentEntry)
  4988.     end
  4989.     else if (upper(EH_Keyword) == 'CALCULATEDATE') | (upper(EH_Keyword) == 'CALCULATEIMAGE') then do
  4990.       EH_DayOfWeek = DateInfo('W', EH_Year''EH_Month''right(EH_EventDay.EH_CurrentEntry, 2, '0'), 'S')
  4991.       if EH_HighlightTypeCyc.EH_HighlightType == 'Float' then do
  4992.         interpret 'EH_DayNumber = Day.'EH_DayOfWeek
  4993.         if EH_Weeknumber.EH_CurrentEntry < 4 then do
  4994.           EH_DayNumber = EH_DayNumber + 1
  4995.           if EH_DayNumber == 7 then EH_DayNumber = 0
  4996.           interpret 'EH_DayOfWeek = Day.'EH_DayNumber
  4997.           EH_EventDay = 7 * (EH_Weeknumber.EH_CurrentEntry + 1)
  4998.         end
  4999.         else do
  5000.           EH_EventDay = Monthlength.EH_ShortMonth
  5001.           EH_TempDay = Monthlength.EH_ShortMonth - 29
  5002.           EH_DayNumber = EH_DayNumber - EH_TempDay
  5003.           if EH_DayNumber < 0 then EH_DayNumber = EH_DayNumber + 7
  5004.           else if EH_DayNumber > 6 then EH_DayNumber = EH_DayNumber - 7
  5005.           interpret 'EH_DayOfWeek = Day.'EH_DayNumber
  5006.         end
  5007.       end
  5008.       else EH_EventDay = "'"EH_WeekTypeCyc.EH_CurrentEntry"'"
  5009.       EH_DataLine = EH_SelectMonth''EH_Keyword'('EH_SelectMonth - 0', 'QuoteIt(EH_DayOfWeek)', 'EH_EventDay', 'QuoteIt(EH_Event.EH_CurrentEntry)
  5010.       if upper(EH_Keyword) == 'CALCULATEDATE' then EH_DataLine = EH_DataLine', 'QuoteIt(EH_Color.EH_CurrentEntry)
  5011.       EH_DataLine = EH_DataLine')'
  5012.     end
  5013.     else if EH_SelectMonth == 14 then
  5014.       EH_DataLine = 'CalculateEDate('EH_EventDay.EH_CurrentEntry', 'QuoteIt(EH_Event.EH_CurrentEntry)', 'QuoteIt(EH_Color.EH_CurrentEntry)')'
  5015.     if EH_Comment.EH_CurrentEntry ~= '' then EH_DataLine = EH_DataLine'  /* 'EH_Comment.EH_CurrentEntry' */'
  5016.     HighlightData.EH_SelectMonth.EH_i = EH_DataLine
  5017.   end
  5018.   MonthCount.EH_SelectMonth = EH_EntryCount
  5019.  
  5020.   return
  5021. /**/
  5022.  
  5023. /***//*** EH_CASetBiOrWeeklyGads ***/
  5024. EH_CASetBiOrWeeklyGads:
  5025.   call ToPIPE('EH', 'id 'EH_ButtonID.LD' dis=1 ref')
  5026.   if EH_EventDay.EH_CurrentEntry == 'LD' then do
  5027.     call ToPIPE('EH', 'id 'EH_ButtonID.LD' s=0 ref')
  5028.     EH_EventDay.EH_CurrentEntry = 1
  5029.     call ToPIPE('EH', 'id 'EH_ButtonID.1' s=1 ref')
  5030.     EH_DayShowing = 1
  5031.   end
  5032.  
  5033.   call ToPIPE('EH', 'id 'EH_HLTypeGad' dis=0 ref')
  5034.   call ToPIPE('EH', 'id 'EH_WeekNumberGad' dis=1 ref')
  5035.   call ToPIPE('EH', 'id 'EH_WeekTypeGad' dis=0 ref')
  5036.   call ToPIPE('EH', 'id 'EH_WeekendGad' dis=1 ref')
  5037.   call ToPIPE('EH', 'id 'EH_HolidayGad' dis=0 ref')
  5038.   return
  5039. /**/
  5040.  
  5041. /***//*** EH_CASetEvent ***/
  5042. EH_CASetEvent:
  5043.   EH_CurrentEntry = EH_Pointer.EH_CurrentPointer
  5044.   call EH_CASetPrevAndNext
  5045.  
  5046.   if EH_SelectMonth < 14 then do
  5047.     /* De-select existing date button */
  5048.     if EH_DayShowing ~= 0 then call ToPIPE('EH', 'id 'EH_ButtonID.EH_DayShowing' s=0 ref')
  5049.     /* Select current date button */
  5050.     EH_EventDay = EH_EventDay.EH_CurrentEntry
  5051.     EH_DayShowing = EH_EventDay
  5052.     EH_HighlightType = EH_HighlightType.EH_CurrentEntry
  5053.     call ToPIPE('EH', 'id 'EH_ButtonID.EH_EventDay' s=1')
  5054.     call ToPIPE('EH', 'id 'EH_HLTypeGad' s='EH_HighlightType.EH_CurrentEntry)
  5055.     if EH_HighlightType.EH_CurrentEntry == 0 then call EH_CASetFixedGads
  5056.     else if EH_HighlightType.EH_CurrentEntry == 1 then do
  5057.       call EH_CASetFloatGads
  5058.       call EH_CACheckWeekNumber
  5059.     end
  5060.     else if EH_HighlightType.EH_CurrentEntry == 2 then do
  5061.       call EH_CASetBiOrWeeklyGads
  5062.       call EH_CACheckWeekType
  5063.     end
  5064.     call ToPIPE('EH', 'id 'EH_WeekendGad' s='EH_Weekend.EH_CurrentEntry)
  5065.     call ToPIPE('EH', 'id 'EH_HolidayGad' s='EH_Holiday.EH_CurrentEntry' ref')
  5066.   end
  5067.   else call ToPIPE('EH', 'id 'EH_EasterGad' defn='EH_Easter.EH_CurrentEntry)
  5068.  
  5069.   call ToPIPE('EH', 'id 'EH_EventGad' gt="'EH_Event.EH_CurrentEntry'" ref')
  5070.   call ToPIPE('EH', 'id 'EH_CommentGad' gt="'EH_Comment.EH_CurrentEntry'" ref')
  5071.   call ToPIPE('EH', 'id 'EH_ColorGad' gt="'EH_Color.EH_CurrentEntry'" ref')
  5072.  
  5073.   return
  5074. /**/
  5075.  
  5076. /***//*** EH_CASetFixedGads ***/
  5077. EH_CASetFixedGads:
  5078.   call ToPIPE('EH', 'id 'EH_ButtonID.LD' dis=0 ref')
  5079.  
  5080.   call ToPIPE('EH', 'id 'EH_ColorGad' dis=0 ref')
  5081.   call ToPIPE('EH', 'id 'EH_HLTypeGad' dis=0 ref')
  5082.   call ToPIPE('EH', 'id 'EH_WeekNumberGad' dis=1 ref')
  5083.   call ToPIPE('EH', 'id 'EH_WeekTypeGad' dis=1 ref')
  5084.   call ToPIPE('EH', 'id 'EH_WeekendGad' dis=0 ref')
  5085.   call ToPIPE('EH', 'id 'EH_HolidayGad' dis=0 ref')
  5086.   call ToPIPE('EH', 'id 'EH_EasterGad' dis=1 ref')
  5087.   return
  5088. /**/
  5089.  
  5090. /***//*** EH_CASetFloatGads ***/
  5091. EH_CASetFloatGads:
  5092.   call ToPIPE('EH', 'id 'EH_ButtonID.LD' dis=1 ref')
  5093.   if EH_EventDay.EH_CurrentEntry == 'LD' then do
  5094.     call ToPIPE('EH', 'id 'EH_ButtonID.LD' s=0 ref')
  5095.     EH_EventDay.EH_CurrentEntry = 1
  5096.     call ToPIPE('EH', 'id 'EH_ButtonID.1' s=1 ref')
  5097.     EH_DayShowing = 1
  5098.   end
  5099.  
  5100.   call ToPIPE('EH', 'id 'EH_ColorGad' dis=0 ref')
  5101.   call ToPIPE('EH', 'id 'EH_HLTypeGad' dis=0 ref')
  5102.   call ToPIPE('EH', 'id 'EH_WeekNumberGad' dis=0 ref')
  5103.   call ToPIPE('EH', 'id 'EH_WeekTypeGad' dis=1 ref')
  5104.   call ToPIPE('EH', 'id 'EH_WeekendGad' dis=1 ref')
  5105.   call ToPIPE('EH', 'id 'EH_HolidayGad' dis=0 ref')
  5106.   call ToPIPE('EH', 'id 'EH_EasterGad' dis=1 ref')
  5107.   return
  5108. /**/
  5109.  
  5110. /***//*** EH_CASetMonthGads ***/
  5111. EH_CASetMonthGads:
  5112.   call ToPIPE('EH', 'id 'EH_EventGad' dis=0 ref')
  5113.   call ToPIPE('EH', 'id 'EH_ChooseEventGad' dis=0 ref')
  5114.   call ToPIPE('EH', 'id 'EH_CommentGad' dis=0 ref')
  5115.   call ToPIPE('EH', 'id 'EH_ColorGad' dis=0 ref')
  5116.  
  5117.   if EH_SelectMonth == 14 then do
  5118.     EH_DisableFlag = 1
  5119.     call ToPIPE('EH', 'id 'EH_HLTypeGad' dis=1 ref')
  5120.     call ToPIPE('EH', 'id 'EH_WeekNumberGad' dis=1 ref')
  5121.     call ToPIPE('EH', 'id 'EH_WeekTypeGad' dis=1 ref')
  5122.     call ToPIPE('EH', 'id 'EH_WeekendGad' dis=1 ref')
  5123.     call ToPIPE('EH', 'id 'EH_EasterGad' dis=0 ref')
  5124.   end
  5125.   else do
  5126.     call ToPIPE('EH', 'id 'EH_EasterGad' dis=1 ref')
  5127.     EH_DisableFlag = 0
  5128.   end
  5129.  
  5130.   do EH_Posn = 0 to 41
  5131.     if GadText.EH_Posn ~= '' then call ToPIPE('EH', 'id 'GadID.EH_Posn' dis='EH_DisableFlag' ref')
  5132.   end
  5133.  
  5134.   call ToPIPE('EH', 'id 'EH_HolidayGad' dis=0 ref')
  5135.   call ToPIPE('EH', 'id 'EH_DeleteEventGad' dis=0 ref')
  5136.  
  5137.   return
  5138. /**/
  5139.  
  5140. /***//*** EH_CASetPrevAndNext ***/
  5141. EH_CASetPrevAndNext:
  5142.   if EH_EntryCount < 2 then do
  5143.     call ToPIPE('EH', 'id 'EH_ListEventGad' dis=1')
  5144.     call ToPIPE('EH', 'id 'EH_CycleEventGad' dis=1')
  5145.   end
  5146.   else do
  5147.     call ToPIPE('EH', 'id 'EH_ListEventGad' dis=0 ref')
  5148.     call ToPIPE('EH', 'id 'EH_CycleEventGad' dis=0 ref')
  5149.   end
  5150.   return
  5151. /**/
  5152.  
  5153. /***//*** EH_CASetRequester ***/
  5154. call EH_CASetRequester:
  5155.   call ToPIPE('EH', 'id 0 s=256')
  5156.   if EH_DayShowing ~= 0 then call ToPIPE('EH', 'id 'EH_ButtonID.EH_DayShowing' s=0 ref')
  5157.   EH_DayShowing = 0
  5158.  
  5159.   EH_ShortMonth = EH_SelectMonth - 0
  5160.   if EH_ShortMonth > 12 then EH_ShortMonth = 1
  5161.   EH_Month = right(EH_ShortMonth, 2, "0")
  5162.   interpret 'EH_StartDate = Day.'DateInfo('W', EH_Year''EH_Month'01', 'S')
  5163.  
  5164.   MonthLength.2 = 29
  5165.   call ToPIPE('EH', 'id 'EH_MonthGad' s='EH_SelectMonth - 1)
  5166.   if EH_SelectMonth ~= 14 then do
  5167.     EH_ButtonID. = 0
  5168.     EH_GadText.  = ''
  5169.     EH_Day       = 0
  5170.     do EH_Week = 0 to 5
  5171.       do EH_WeekDay = 0 to 6
  5172.         EH_Posn = (EH_Week * 7) + EH_WeekDay
  5173.         if (EH_Posn >= EH_StartDate) & (EH_Posn < EH_StartDate + MonthLength.EH_ShortMonth + 1) then do
  5174.           EH_Day = EH_Day + 1
  5175.           if EH_Day > MonthLength.EH_ShortMonth then EH_Day = LD
  5176.           GadText.EH_Posn = EH_Day
  5177.           EH_ButtonID.EH_Day = GadID.EH_Posn
  5178.           interpret 'EH_Day.'GadID.EH_Posn' = EH_Day'
  5179.           call ToPIPE('EH', 'id 'GadID.EH_Posn' gt="'EH_Day'" dis=0')
  5180.         end
  5181.         else do
  5182.           GadText.EH_Posn = ''
  5183.           interpret 'drop EH_Day.'GadID.EH_Posn
  5184.           call ToPIPE('EH', 'id 'GadID.EH_Posn' gt="" dis=1')
  5185.         end
  5186.       end
  5187.     end
  5188.   end
  5189.  
  5190.   if UpdateBusy(Req, 1) == -1 then call EH_CACleanup
  5191.   call EH_CAReadData
  5192.  
  5193.   if UpdateBusy(Req, 1) == -1 then call EH_CACleanup
  5194.   EH_DayShowing = 0
  5195.   if EH_EntryCount > 0 then do
  5196.     call EH_CASetMonthGads
  5197.     call EH_CASetEvent
  5198.   end
  5199.   else call EH_CAGhostGads
  5200.  
  5201.   call ToPIPE('EH', 'id 0 s=512')
  5202.   return
  5203. /**/
  5204.  
  5205. /***//*** EH_CASortAndFind ***/
  5206. EH_CASortAndFind:
  5207.   parse arg SAF_CurrentEntry
  5208.   SortFile = ''
  5209.   do EH_i = 1 to EH_EntryCount
  5210.     SortFile = SortFile''right(EH_i, 3, "0")' 'EH_EventDay.EH_i||'0a'x
  5211.   end
  5212.   call writefile('pipe:FWC', strip(SortFile, 'B', '0a'x))
  5213.   address command 'sort pipe:FWC Pipe:FWC1 Colstart 5 numeric'
  5214.   SortedFile = ReadFile('pipe:FWC1')
  5215.   call openv('SortedFile')
  5216.   do EH_i = 1 to EH_EntryCount
  5217.     EH_Pointer.EH_i = left(readvln('SortedFile'), 3) - 0
  5218.     if EH_Pointer.EH_i == SAF_CurrentEntry then EH_CurrentPointer = EH_i
  5219.   end
  5220.   call closev('SortedFile')
  5221.   call EH_CAUpdateEventList
  5222.   call EH_CASetPrevAndNext
  5223.   return
  5224. /**/
  5225.  
  5226. /***//*** EH_CAUpdateEventList ***/
  5227. EH_CAUpdateEventList:
  5228.   EH_EventList = ''
  5229.   do UEL_i = 1 to EH_EntryCount
  5230.     EH_Entry = EH_Pointer.UEL_i
  5231.     EH_EventList = EH_EventList'|'EH_Event.EH_Entry
  5232.   end
  5233.   EH_EventList = strip(EH_EventList, 'L', '|')
  5234.   call ToPipe('EH', 'id 'EH_ListEventGad' defn='EH_EntryCount' cl="'EH_EventList'"')
  5235.  
  5236.   return
  5237. /**/
  5238.  
  5239. /**/
  5240.  
  5241. /**/
  5242.  
  5243. /***//*** FilePart (PROCEDURE) ***/
  5244. FilePart: PROCEDURE
  5245.   parse arg FileWithPath
  5246.   return substr(FileWithPath, max(lastpos(':', FileWithPath), lastpos('/', FileWithPath)) + 1)
  5247. /**/
  5248.  
  5249. /***//*** GetAppColors () ***/
  5250. GetAppColors:
  5251.   if App == 'FW' then do
  5252.     FWPrefs = ReadFile(CurrentDir'FWFiles/FW.Prefs')
  5253.     ColorTable = pos('SWCL', FWPrefs) + 12
  5254.     EndTable = pos('STUP', FWPrefs)
  5255.     ColorCount = 0
  5256.     Do CTPos = ColorTable to EndTable by 20
  5257.       ColorRegister.ColorCount = c2x(substr(FWPrefs, CTPos - 3, 3))
  5258.       ColorList.ColorCount = strip(substr(FWPrefs, CTPos, 16), 'B', '00'x)
  5259.       NCColorList.ColorCount = ColorList.ColorCount
  5260.       if ColorRegister.ColorCount = '000000' then Black$ = ColorList.ColorCount
  5261.       if ColorRegister.ColorCount = 'FFFFFF' then White$ = ColorList.ColorCount
  5262.       ColorCount = ColorCount + 1
  5263.     end
  5264.     NCColorCount = ColorCount
  5265.     NCColorList.COUNT = NCColorCount
  5266.     ColorList.ColorCount = '<'Clear$'>'
  5267.     ColorCount = ColorCount + 1
  5268.     ColorList.COUNT = ColorCount
  5269.     if symbol('Black$') == 'LIT' then do
  5270.       call AddMsg('W', "The color black can't be found; "ColorList.0" used instead.")
  5271.       Black$ = ColorList.0
  5272.     end
  5273.     if symbol('White$') == 'LIT' then do
  5274.       call AddMsg('W', "The color white can't be found; "ColorList.1" used instead.")
  5275.       White$ = ColorList.1
  5276.     end
  5277.   end
  5278.   else if App == 'PGS' then do
  5279.     GETFONTLIST FontList
  5280.     FontList.COUNT = result
  5281.  
  5282.     PGSColors = ReadFile(CurrentDir''PgmName'.colors')
  5283.     ColorCount = 0
  5284.     StartTag = pos('TG'||'00'x, PGSColors)
  5285.     do while StartTag ~= 0
  5286.       Color = substr(PGSColors, StartTag + 10, c2d(substr(PGSColors, StartTag + 9, 1)))
  5287.       AccentMarker = pos(d2c(129), Color)
  5288.       do while AccentMarker > 0
  5289.         Color = overlay(d2c(c2d(substr(Color, AccentMarker + 1, 1)) + 128), delstr(Color, AccentMarker, 1), AccentMarker)
  5290.         AccentMarker = pos(d2c(129), Color)
  5291.       end
  5292.       ColorList.ColorCount = Color
  5293.       NCColorList.ColorCount = ColorList.ColorCount
  5294.       ColorCount = ColorCount + 1
  5295.       StartTag = pos('TG'||'00'x, PGSColors, StartTag + 10)
  5296.     end
  5297.     NCColorCount = ColorCount
  5298.     NCColorList.COUNT = NCColorCount
  5299.     ColorList.ColorCount = '<'Clear$'>'
  5300.     ColorCount = ColorCount + 1
  5301.     ColorList.COUNT = ColorCount
  5302.     White$ = ColorList.0
  5303.     Black$ = ColorList.1
  5304.   end
  5305.  
  5306.   DefaultColor = Black$
  5307.   DefaultBackground = White$
  5308.  
  5309.   return
  5310. /**/
  5311.  
  5312. /***//*** GetFontWidth (GFW) ***/
  5313. GetFontWidth:
  5314.   parse arg GFW_FontType, GFW_FontStyle, GFW_Char
  5315.  
  5316.   GFW_ID = PrintText(.5, .5, GFW_FontType, GFW_FontStyle, Black$, Width.GFW_FontType, GFW_Char)
  5317.  
  5318.   if App == 'FW' then do
  5319.     REDRAW
  5320.     GETOBJECTCOORDS GFW_ID; parse var RESULT . . . GFW_Width .
  5321.     DELETEOBJECT GFW_ID
  5322.   end
  5323.   else if App == 'PGS' then do
  5324.     GETTEXTOBJ POSITION GFW_Text OBJECTID GFW_ID WINDOW winName
  5325.     GFW_Width = GFW_Text.Right - GFW_Text.Left
  5326.     DELETEOBJECT OBJECTID GFW_ID WINDOW winName
  5327.   end
  5328.  
  5329.   return GFW_Width
  5330. /**/
  5331.  
  5332. /***//*** GetHeight (GH) ***/
  5333. GetHeight:
  5334.   parse arg GH_FontType
  5335.  
  5336.   if App == 'FW' then do
  5337.     TEXTBLOCKTYPEPREFS SIZE FSize.GH_FontType FONT Font.GH_FontType
  5338.     DRAWTEXTBLOCK 1 1 1 'A'; GH_id = result
  5339.     GETOBJECTCOORDS GH_id; Parse Var result . . . . GH_Text.Height
  5340.   end
  5341.   else if App == 'PGS' then do
  5342.     DRAWTEXTOBJ 0 0 WINDOW winName; GH_id = result
  5343.     SELECTTEXT AT 0 0 WINDOW winName
  5344.     BEGINCOMMANDCAPTURE
  5345.       SETLEADING RELATIVE 100
  5346.       SETTYPESIZE FSize.GH_FontType WINDOW winName
  5347.       SETFONT Font.GH_FontType WINDOW winName
  5348.     ENDCOMMANDCAPTURE
  5349.     INSERT 'A' WINDOW winName
  5350.     GETTEXTOBJ POSITION GH_Text OBJECTID GH_id WINDOW winName
  5351.     GH_Text.Height = GH_Text.Bottom - GH_Text.Top
  5352.     DELETEOBJECT OBJECTID GH_id WINDOW winName
  5353.   end
  5354.  
  5355.   return GH_Text.Height
  5356. /**/
  5357.  
  5358. /***//*** GetID (GI) ***/
  5359. GetID:
  5360. parse arg GI_var
  5361.  
  5362. return id.GI_var
  5363. /**/
  5364.  
  5365. /***//*** GetMaxWidth (GMW) ***/
  5366. GetMaxWidth:
  5367.   parse arg GMW_Stem, GMW_Count
  5368.  
  5369.   GMW_maxwidth = 0
  5370.  
  5371.   if App == 'FW' then do
  5372.     do GMW_i = 0 to GMW_Count
  5373.       interpret 'GMW_ObjectID = 'GMW_Stem'.'GMW_i
  5374.       GETOBJECTCOORDS GMW_ObjectID
  5375.       Parse Var result . . . GMW_width .
  5376.       GMW_maxwidth = max(GMW_width, GMW_maxwidth)
  5377.     end
  5378.   end
  5379.   else if App == 'PGS' then do
  5380.     do GMW_i = 0 to GMW_Count
  5381.       interpret 'GMW_ObjectID = 'GMW_Stem'.'GMW_i
  5382.       SELECTOBJECT ObjectID GMW_ObjectID WINDOW winName
  5383.       GETTEXTOBJ POSITION GMW_Temp OBJECTID GMW_ObjectID WINDOW winName
  5384.       GMW_width = GMW_Temp.Right - GMW_Temp.Left
  5385.       GMW_maxwidth = max(GMW_width, GMW_maxwidth)
  5386.     end
  5387.   end
  5388.  
  5389.   return GMW_maxwidth
  5390. /**/
  5391.  
  5392. /***//*** GetMiniMax (GMM) ***/
  5393. GetMiniMax:
  5394.   parse arg GMM_FontType
  5395.  
  5396.   NormalWidth.Widest = 0
  5397.   BoldWidth.Widest = 0
  5398.   do GMM_i = 0 to 9
  5399.     NormalWidthID.GMM_i = PrintText(1, 1, GMM_FontType, 'N', Black$, Width.GMM_FontType, GMM_i)
  5400.     BoldWidthID.GMM_i = PrintText(1, 1, GMM_FontType, 'B', Black$, Width.GMM_FontType, GMM_i)
  5401.   end
  5402.   if App == 'FW' then REDRAW
  5403.   do GMM_i = 0 to 9
  5404.     NormalWidth.GMM_i = GetWidth(NormalWidthID.GMM_i)
  5405.     BoldWidth.GMM_i = GetWidth(BoldWidthID.GMM_i)
  5406.     NormalWidth.Widest = max(NormalWidth.Widest, NormalWidth.GMM_i)
  5407.     BoldWidth.Widest = max(BoldWidth.Widest, BoldWidth.GMM_i)
  5408.     if App == 'PGS' then do
  5409.       DELETEOBJECT OBJECTID NormalWidthID.GMM_i WINDOW winName
  5410.       DELETEOBJECT OBJECTID BoldWidthID.GMM_i WINDOW winName
  5411.     end
  5412.   end
  5413.  
  5414.   return
  5415. /**/
  5416.  
  5417. /***//*** GetPhases (GP) ***/
  5418. GetPhases:
  5419.   parse arg GP_Y, GP_Month
  5420.   if DateLib == 1 then do
  5421.     GP_Phase.0 = 'N'
  5422.     GP_Phase.1 = '1'
  5423.     GP_Phase.2 = 'F'
  5424.     GP_Phase.3 = '3'
  5425.  
  5426.     GP_JD = date_GregorianToJD(1, GP_Month, GP_Y)
  5427.     do GP_SeqDate = GP_JD - 22 to GP_JD + 39
  5428.       call date_JDToGregorian(GP_SeqDate, 'GP_DAY GP_MONTH GP_YEAR')
  5429.  
  5430.       do GP_Phase = 0 to 3
  5431.         GP_SeqDate = date_GregorianMoonPhase(GP_Day, GP_Month, GP_Year, GP_Phase)
  5432.         call date_JDToGregorian(GP_SeqDate, 'GP_DAY GP_MONTH GP_YEAR')
  5433.         MoonPhase.GP_Year.GP_Month.GP_Day = GP_Phase.GP_Phase
  5434.       end
  5435.     end
  5436.   end
  5437.   else do
  5438.     /* Routine to determine the dates of the new and full moons for a given year */
  5439.     /* obtained from the Sky & Telescope web site. The basic program from which  */
  5440.     /* the following was derived originally appeared in Astronomical Computing,  */
  5441.     /* Sky & Telescope, March, 1985                                              */
  5442.     GP_R1 = PI(0) / 180
  5443.     GP_NextPhase = 29.530588853 / 4
  5444.     GP_U  = 0
  5445.  
  5446.     GP_K0 = trunc((GP_Y - 1900) * 12.3685)
  5447.     GP_T  = (GP_Y - 1899.5) / 100
  5448.     GP_T2 = GP_T*GP_T
  5449.     GP_T3 = GP_T*GP_T*GP_T
  5450.     GP_J0 = 2415020 + 29 * GP_K0
  5451.     GP_F0 = 0.0001178 * GP_T2 - 0.000000155 * GP_T3 + 0.75933 + 0.53058868 * GP_K0 - 0.000837 * GP_T - 0.000335 * GP_T2
  5452.  
  5453.     GP_J0  = GP_J0 + trunc(GP_F0)
  5454.     GP_F0  = GP_F0 - trunc(GP_F0)
  5455.  
  5456.     GP_M0 = GP_K0 * 0.08084821133
  5457.     GP_M0 = 360 * (GP_M0 - trunc(GP_M0)) + 359.2242 - 0.0000333 * GP_T2 - 0.00000347 * GP_T3
  5458.     GP_M1 = GP_K0 * 0.07171366128
  5459.     GP_M1 = 360 * (GP_M1 - trunc(GP_M1)) + 306.0253 + 0.0107306 * GP_T2 + 0.00001236 * GP_T3
  5460.     GP_B1 = GP_K0 * 0.08519585128
  5461.     GP_B1 = 360 * (GP_B1 - trunc(GP_B1)) + 21.2964 - 0.0016528 * GP_T2 - 0.00000239 * GP_T3
  5462.     do GP_K9 = 0 to 28
  5463.       GP_J  = GP_J0 + 14 * GP_K9
  5464.       GP_F  = GP_F0 + 0.765294 * GP_K9
  5465.       GP_K  = GP_K9 / 2
  5466.       GP_M5 = (GP_M0 + GP_K * 29.10535608) * GP_R1
  5467.       GP_M6 = (GP_M1 + GP_K * 385.81691806) * GP_R1
  5468.       GP_B6 = (GP_B1 + GP_K * 390.67050646) * GP_R1
  5469.       GP_F  = GP_F - 0.4068 * SIN(GP_M6) + (0.1734 - 0.000393 * GP_T) * SIN(GP_M5) + 0.0161 * SIN(2 * GP_M6)
  5470.       GP_F  = GP_F + 0.0104 * SIN(2 * GP_B6) - 0.0074 * SIN(GP_M5 - GP_M6) - 0.0051 * SIN(GP_M5 + GP_M6)
  5471.       GP_F  = GP_F + 0.0021 * SIN(2 * GP_M5) + 0.0010 * SIN(2 * GP_B6 - GP_M6)
  5472.       GP_J  = GP_J + trunc(GP_F)
  5473.       GP_F  = GP_F - trunc(GP_F)
  5474.  
  5475.       GP_Converted  = ConvertJ(GP_F, GP_J)
  5476.       GP_Y          = word(GP_Converted, 1) - 0
  5477.       GP_M          = word(GP_Converted, 2) - 0
  5478.       GP_Day        = word(GP_Converted, 3) - 0
  5479.       GP_Hrs        = word(GP_Converted, 4)
  5480.       if GP_U = 0 then do
  5481.         MoonPhase.GP_Y.GP_M.GP_Day = 'N'
  5482.         GP_FQ = DateInfo('S', trunc(DateInfo('I', GP_Y''right(GP_M, 2, '0')''right(GP_Day, 2, '0'), 'S') + GP_Hrs + GP_NextPhase))
  5483.         GP_Y = left(GP_FQ, 4)
  5484.         GP_M = strip(substr(GP_FQ, 5, 2), 'L', '0')
  5485.         GP_Day = strip(right(GP_FQ, 2), 'L', '0')
  5486.         MoonPhase.GP_Y.GP_M.GP_Day = '1'
  5487.       end
  5488.       if GP_U = 1 then do
  5489.         MoonPhase.GP_Y.GP_M.GP_Day = 'F'
  5490.         GP_TQ = DateInfo('S', trunc(DateInfo('I', GP_Y''right(GP_M, 2, '0')''right(GP_Day, 2, '0'), 'S') + GP_Hrs + GP_NextPhase))
  5491.         GP_Y = left(GP_TQ, 4)
  5492.         GP_M = strip(substr(GP_TQ, 5, 2), 'L', '0')
  5493.         GP_Day = strip(right(GP_TQ, 2), 'L', '0')
  5494.         MoonPhase.GP_Y.GP_M.GP_Day = '3'
  5495.       end
  5496.       GP_U = GP_U + 1
  5497.       if GP_U = 2 then GP_U = 0
  5498.     end
  5499.   end
  5500. return 0
  5501. /**/
  5502.  
  5503. /***//*** GetSetupInfo (GSI) ***/
  5504. GetSetupInfo:
  5505.   if exists(ScriptDir'FWC.dat') then call ConvertChangesFile
  5506.   else do
  5507.     PrefsFile = ReadFile('ENV:FWCalendar') /* Determine existing data file */
  5508.     if (PrefsFile == '') | (exists(PrefsFile) == 0) then do
  5509.       /* Create environment variable if it doesn't exist */
  5510.       PrefsFile = 'Default'
  5511.       call WriteFile('ENV:FWCalendar', PrefsFile, 'B')
  5512.     end
  5513.   end
  5514.  
  5515.   if PrefsFile ~= 'Default' then do
  5516.     GSI_Data = ReadFile(PrefsFile)
  5517.     GSI_UpperData = upper(GSI_Data)
  5518.     interpret ReadToEOL(pos('STORAGE', GSI_UpperData), GSI_UpperData)
  5519.     interpret ReadToEOL(pos('FORCEBGUI', GSI_UpperData), GSI_UpperData)
  5520.     interpret ReadToEOL(pos('HOSTSCREEN', GSI_UpperData), GSI_UpperData)
  5521.  
  5522.     if (ForceBGUI == 1) & (RexxBGUILib ~= 1) then call AddBGUI
  5523.     if HostScreen ~= '' then AppScreen = HostScreen
  5524.   end
  5525.  
  5526.   call GetAppColors
  5527.   if App == 'PGS' then do
  5528.     GETDOCUMENTS dummy; DocCount = result
  5529.     if DocCount > 0 then do
  5530.       CLOSEDOCUMENT ALERT
  5531.       GETDOCUMENTS dummy; DocCount = result
  5532.     end
  5533.   end
  5534.  
  5535.   if ClassAct == 1 then Req = OpenBusy(PrepReq$, 21 + (ColorList.Count - 1))
  5536.   else Req = OpenBusy(PrepReq$, 14)
  5537.  
  5538.   Year = left(date('S'),4)
  5539.   ThisMonth = left(date('U'), 2) + 0
  5540.  
  5541.   if (owner == 'rgoertz') & (CallHost == 'REXX') then CalMonth = ThisMonth
  5542.   else do
  5543.     CalMonth = getclip('FWC_CalMonth')
  5544.     if datatype(CalMonth) == 'CHAR' then do
  5545.       CalMonth = ThisMonth
  5546.       AddYear = 0
  5547.     end
  5548.     else do
  5549.       CalMonth = CalMonth + 1
  5550.       if CalMonth = 13 then do
  5551.         CalMonth = 1
  5552.         AddYear = 1
  5553.       end
  5554.       else AddYear = 0
  5555.     end
  5556.     CalYear = getclip('FWC_CalYear')
  5557.     if (CalYear ~= '') & (DataType(CalYear) == 'NUM') then Year = CalYear + AddYear
  5558.   end
  5559.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  5560.  
  5561.   call InitializeVariables
  5562.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  5563.  
  5564.   address command 'makedir >NIL: 'left(Storage, length(Storage) - 1)
  5565.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  5566.  
  5567.   WarningsSoFar = WarningCount
  5568.   if ClassAct == 1 then call DoSetupReq_CA
  5569.   else do
  5570.     do until Reset == 0
  5571.       if Req == 0 then Req = OpenBusy(PrepReq$, 11)
  5572.       WarningCount = WarningsSoFar
  5573.       call ReadData
  5574.       if UpdateBusy(Req, 1) == -1 then call Cleanup
  5575.       call DoSetupReq_BGUI
  5576.       if Reset > 0 then call bguiwinclose(winID)
  5577.       if Reset == 2 then call CleanUp
  5578.     end
  5579.   end
  5580.  
  5581.   Year = EnteredYear
  5582.  
  5583.   if ImageClass.0 ~= '' then do
  5584.     do GSI_i = 0 to ImageClass.Count - 1
  5585.       parse var ImageFile.GSI_i ImageFile.GSI_i ',' GSI_DX ',' GSI_DY
  5586.       GSI_DX = strip(GSI_DX, 'B', '" '||"'");if GSI_DX == '' then GSI_DX = 0
  5587.       GSI_DY = strip(GSI_DY, 'B', '" '||"'");if GSI_DY == '' then GSI_DY = 0
  5588.       if (pos('/', ImageFile.GSI_i) == 0) & (pos(':', ImageFile.GSI_i) == 0) then
  5589.         ImageFile.GSI_i = ScriptDir'Images/'strip(ImageFile.GSI_i, 'B', ' "'||"'")
  5590.       ImageDX.GSI_i = GSI_DX
  5591.       ImageDY.GSI_i = GSI_DY
  5592.     end
  5593.   end
  5594.  
  5595.   call WriteData
  5596.  
  5597.   if ClassAct == 1 then call close('CA')
  5598.   else call bguiwinclose(winID)
  5599.  
  5600.   interpret 'GfxCmd = GfxCmd.'GfxApp
  5601.   interpret 'GfxTemplate = GfxTemplate.'GfxApp
  5602.  
  5603.   return
  5604. /**/
  5605.  
  5606. /***//*** GetSRSS (GS) ***/
  5607. GetSRSS:
  5608.   parse arg GS_IDay
  5609.  
  5610.   GS_EDay = translate(DateInfo('E', GS_IDay, 'I'), '-', '/')
  5611.   if AdjustDST ~= 0 then do
  5612.     if GS_IDay < StartDST | GS_IDay >= EndDST then GS_Status = WriteFile('ENV:suncalc/dst', 0)
  5613.     else GS_Status = WriteFile('ENV:suncalc/dst', 1)
  5614.   end
  5615.   address command Storage'suncalc > 'Storage'SRSS.txt date='GS_EDay' text="$SR $SS"'
  5616.   return ReadFile(Storage'SRSS.txt')
  5617. /**/
  5618.  
  5619. /***//*** GetWidth (GW) ***/
  5620. GetWidth:
  5621.   parse arg GW_ID
  5622.  
  5623.   if App == 'FW' then do
  5624.     GETOBJECTCOORDS GW_ID
  5625.     Parse Var result . . . GW_width .
  5626.   end
  5627.   else if App == 'PGS' then do
  5628.     SELECTOBJECT OBJECTID GW_ID WINDOW winName
  5629.     GETTEXTOBJ POSITION GW_Temp OBJECTID GW_ID WINDOW winName
  5630.     GW_width = GW_Temp.Right - GW_Temp.Left
  5631.   end
  5632.  
  5633.   return GW_width
  5634. /**/
  5635.  
  5636. /***//*** HalveBox (HB) ***/
  5637. HalveBox:
  5638.   parse arg HB_ID
  5639.  
  5640.   if App == 'FW' then do
  5641.     GETOBJECTCOORDS HB_ID
  5642.     parse var result . HB_Left HB_Top HB_Width HB_Height
  5643.     SETOBJECTCOORDS HB_ID 1 HB_Left HB_Top HB_Width HB_Height/2
  5644.   end
  5645.   else if App == 'PGS' then do
  5646.     GETBOX POSITION HB_Coords OBJECTID HB_ID WINDOW winName
  5647.     HB_Bottom = HB_Coords.Top + (HB_Coords.Bottom - HB_Coords.Top) / 2
  5648.     EDITBOX POSITION HB_Coords.Left HB_Coords.Top HB_Coords.Right HB_Bottom OBJECTID HB_ID WINDOW winName
  5649.   end
  5650.  
  5651.   return HB_ID
  5652. /**/
  5653.  
  5654. /***//*** PgmVer (PROCEDURE) ***/
  5655. PgmVer: PROCEDURE
  5656.   parse arg Program
  5657.  
  5658.   address command 'version 'Program '>PIPE:FWC file'
  5659.  
  5660.   return strip(word(ReadFile('PIPE:FWC'), 2))
  5661. /**/
  5662.  
  5663. /***//*** MemberID (MI) ***/
  5664. MemberID:
  5665.   parse arg MI_Member, MI_Array, MI_Count, MI_Start
  5666.  
  5667.   if MI_Count == '' then interpret 'MI_Count = 'MI_Array'.Count'
  5668.   if MI_Start == '' then do
  5669.     if symbol(MI_Array'.Start') == 'VAR' then interpret 'MI_Start = 'MI_Array'.Start'
  5670.     else MI_Start = 0
  5671.   end
  5672.  
  5673.   do MI_i = MI_Start to MI_Start + MI_Count - 1
  5674.     if upper(value(MI_Array'.'MI_i)) == upper(MI_Member) then return MI_i
  5675.   end
  5676.   return -1
  5677. /**/
  5678.  
  5679. /***//*** MiniCalPreCalc (MCPC) ***/
  5680. MiniCalPreCalc:
  5681.   parse arg MCPC_FontType, MCPC_CalWidth
  5682.  
  5683.   Width.MCPC_FontType = 100 * min(1, MCPC_CalWidth / (22 * BoldWidth.Widest))
  5684.   if App == 'FW' then Width.MCPC_FontType = trunc(Width.MCPC_FontType)
  5685.  
  5686.   do MCPC_i = 0 to 9
  5687.     NormalWidth.MCPC_i = NormalWidth.MCPC_i * Width.MCPC_FontType / 100
  5688.     BoldWidth.MCPC_i   = BoldWidth.MCPC_i * Width.MCPC_FontType / 100
  5689.   end
  5690.   NormalWidth.Widest = NormalWidth.Widest * Width.MCPC_FontType / 100
  5691.   BoldWidth.Widest = BoldWidth.Widest * Width.MCPC_FontType / 100
  5692. return
  5693. /**/
  5694.  
  5695. /***//*** ParseVariables (PV) ***/
  5696. ParseVariables:
  5697. parse arg PV_Line
  5698.  
  5699. PV_String = translate(PV_Line,,'=(+-*/,)"'||"'",' ')
  5700. PV_VarString = ''
  5701. PV_Var.      = '00'x
  5702. PV_LongVar   = 4
  5703. PV_LIT       = ''
  5704. PV_Count     = 0
  5705.  
  5706. do PV_i = 1 to words(PV_String)
  5707.   PV_Word = word(PV_String, PV_i)
  5708.   if pos(PV_Word'(', PV_Line) > 0 then iterate
  5709.   if datatype(PV_Word) == 'CHAR' then do
  5710.     if (symbol(PV_Word) == 'LIT') then PV_LIT = PV_LIT''PV_Word', '
  5711.     if (symbol(PV_Word) == 'VAR') | (pos('.', PV_Word) > 0) then do
  5712.       if symbol(PV_Word) == 'VAR' then do
  5713.         PV_LongVar = max(PV_LongVar, length(PV_Word) + 2)
  5714.         if PV_Var.PV_Word == '00'x then do
  5715.           PV_Count = PV_Count + 1
  5716.           PV_Var.PV_Count = PV_Word
  5717.           PV_Var.PV_Word  = value(PV_Word)
  5718.         end
  5719.       end
  5720.       if pos('.', PV_Word) > 0 then do
  5721.         PV_CompoundParts = subword(translate(PV_Word,,'.', ' '), 2)
  5722.         do PV_j = 1 to words(PV_CompoundParts)
  5723.           PV_Subword = word(PV_CompoundParts, PV_j)
  5724.           PV_LongVar = max(PV_LongVar, length(PV_SubWord) + 2)
  5725.           if PV_Var.PV_SubWord == '00'x then do
  5726.             PV_Count = PV_Count + 1
  5727.             PV_Var.PV_Count = PV_SubWord
  5728.             if symbol(PV_Subword) == 'LIT' then PV_Var.PV_SubWord  = 'LIT'
  5729.             else PV_Var.PV_SubWord  = value(PV_SubWord)
  5730.           end
  5731.         end
  5732.       end
  5733.     end
  5734.   end
  5735. end
  5736.  
  5737. do PV_i = 1 to PV_Count
  5738.   PV_Word = PV_Var.PV_i
  5739.   if length(PV_Var.PV_Word) > 50 then PV_Var.PV_Word = left(PV_Var.PV_Word, 50)'...'
  5740.   PV_Var.PV_Word = translate(PV_Var.PV_Word,,'0a'x||'0d'x||'00'x,'bb'x)
  5741.   PV_VarString = PV_VarString''right(PV_Word, PV_LongVar)' = 'PV_Var.PV_Word||'0a'x
  5742. end
  5743.  
  5744. if PV_LIT ~= '' then PV_VarString = right('LIT', PV_LongVar)' = 'strip(PV_LIT, 'B', ' ,')||'0a'x||PV_VarString
  5745. return PV_VarString
  5746. /**/
  5747.  
  5748. /***//*** PathPart (PROCEDURE) ***/
  5749. PathPart: PROCEDURE
  5750.   parse arg FileWithPath
  5751.   return left(FileWithPath, max(lastpos(':', FileWithPath), lastpos('/', FileWithPath)))
  5752. /**/
  5753.  
  5754. /***//*** Pi (PROCEDURE) ***/
  5755. Pi:
  5756.   return 3.1415926536
  5757. /**/
  5758.  
  5759. /***//*** PrintHighlight (PH) ***/
  5760. PrintHighlight:
  5761.   parse arg PH_Event, PH_Type
  5762.  
  5763.   PH_Type = upper(PH_Type)
  5764.   MaxCompression = MinWidth / 100
  5765.   CenterText = 0
  5766.   if PH_Type ~= 'HIGHLIGHT' then do
  5767.     HighlightOffset = 0
  5768.     if PH_Type == 'RANDOM' then do
  5769.       MaxCompression = MinRandomWidth / 100
  5770.       if BackgroundColor == '<'Clear$'>' then TextColor = Color.Random
  5771.       else TextColor = AltColor.Random
  5772.       CenterText = CenterRandom
  5773.     end
  5774.     if PH_Type == 'HISTORY' then do
  5775.       MaxCompression = MinHistoryWidth / 100
  5776.       if BackgroundColor == '<'Clear$'>' then TextColor = Color.History
  5777.       else TextColor = AltColor.History
  5778.       CenterText = CenterHistory
  5779.     end
  5780.   end
  5781.  
  5782.   /* Fit line(s) into allowable space */
  5783.   PH_Textline         = 0
  5784.   PH_Text.            = ''
  5785.   PH_Text.PH_Textline = PH_Event
  5786.  
  5787.   Do until PH_Text.PH_Nextline == ''
  5788.     PH_AllowedWidth = BoxWidth - 2 * CurveOffset - HighlightOffset
  5789.     PH_Nextline = PH_Textline + 1
  5790.     if PH_Textline == 0 then PH_Indent.PH_Textline = 0
  5791.     else PH_Indent.PH_Textline = Width.WidthOfDate1
  5792.     if (PH_Type == 'RANDOM') | (PH_Type == 'HISTORY') then PH_Indent.PH_Textline = 0
  5793.     PH_AllowedWidth = PH_AllowedWidth - PH_Indent.PH_Textline
  5794.  
  5795.     if PH_Event == '' then do
  5796.       PH_Text.PH_TextLine = ''
  5797.       iterate
  5798.     end
  5799.     if App == 'FW' & length(PH_Text.PH_Textline) > 37 then do
  5800.       PH_Wordbreak = lastpos(' ', PH_Text.PH_Textline, 37)
  5801.       PH_Text.PH_Nextline = strip(substr(PH_Text.PH_Textline, PH_Wordbreak)' 'PH_Text.PH_Nextline)
  5802.       PH_Text.PH_Textline = strip(left(PH_Text.PH_Textline, PH_Wordbreak))
  5803.     end
  5804.     PH_ID = PrintText(1, 1, Highlight, 'N', Color.Highlight, Width.Highlight, PH_Text.PH_Textline)
  5805.     if App == 'FW' then redraw
  5806.     PH_TextWidth.PH_Textline = GetWidth(PH_ID)
  5807.     if App == 'FW' then DELETEOBJECT PH_ID
  5808.     else if App == 'PGS' then do
  5809.       SELECTOBJECT ObjectID PH_ID WINDOW winName
  5810.       DELETEOBJECT ObjectID PH_ID WINDOW winName
  5811.     end
  5812.  
  5813.     PH_NeededCompression.PH_Textline = min(1, PH_AllowedWidth/PH_TextWidth.PH_Textline)
  5814.     if (PH_NeededCompression.PH_Textline < MaxCompression) & (Words(PH_Text.PH_Textline) > 1) then do
  5815.       /* Move last word to next line */
  5816.       PH_Wordbreak     = lastpos(' ', PH_Text.PH_Textline)
  5817.       PH_Text.PH_Nextline = strip(substr(PH_Text.PH_Textline, PH_Wordbreak)' 'PH_Text.PH_Nextline)
  5818.       PH_Text.PH_Textline = strip(left(PH_Text.PH_Textline, PH_Wordbreak))
  5819.     end
  5820.     else if PH_Text.PH_Nextline ~= '' then PH_Textline = PH_Textline + 1
  5821.   end
  5822.  
  5823.   if PH_Text.0 ~= '' then do
  5824.     PH_LineCount = PH_Textline
  5825.     MaxCompression = 1
  5826.     do PH_i = 0 to PH_LineCount
  5827.       MaxCompression = min(MaxCompression, PH_NeededCompression.PH_i)
  5828.     end
  5829.     PH_Width = MaxCompression * Width.Highlight
  5830.     if App == 'FW' then PH_Width = min(max(trunc(PH_Width), 4), 255)
  5831.  
  5832.     if (PH_Type == 'RANDOM') | (PH_Type == 'HISTORY') then  DailyHLCount = HighlightRows - PH_LineCount - 1
  5833.  
  5834.     do PH_TextLine = 0 to PH_LineCount
  5835.       if PH_Text.PH_TextLine ~= '' then do
  5836.         TextLeft = BoxLeft + CurveOffset + HighlightOffset * (DailyHLCount * Height.Highlight < Height.Date * TextBase)
  5837.         PH_TextTop = BoxTop + DailyHLCount * Height.Highlight
  5838.         if (BHeight == BoxHeight/2) & (PH_Type ~= 'HIGHLIGHT') then PH_TextTop = PH_TextTop - BHeight
  5839.         if CenterText == 0 then call PrintText(TextLeft + PH_Indent.PH_TextLine, PH_TextTop, Highlight, 'N', TextColor, PH_Width, PH_Text.PH_TextLine)
  5840.         else call CenterText(PrintText(TextLeft + PH_Indent.PH_TextLine, PH_TextTop, Highlight, 'N', TextColor, PH_Width, PH_Text.PH_TextLine), BoxLeft + BoxWidth / 2, 0, 1)
  5841.       end
  5842.       if PH_TextLine ~= PH_LineCount then DailyHLCount = DailyHLCount + 1
  5843.     end
  5844.   end
  5845.  
  5846.   return
  5847. /**/
  5848.  
  5849. /***//*** PrintOption (PO) ***/
  5850. PrintOption:
  5851.   parse arg PO_Location
  5852.  
  5853.   PO_ID = PrintText(BoxLeft + CurveOffset, BoxTop + (BHeight - Height.Extras) * (left(PO_Location, 1) ~= 'T'), Extras, 'N', DO_PrintColor, Width.Extras, DO_Text2Print)
  5854.   if right(PO_Location, 1) == 'C' then call CenterText(PO_ID, BoxLeft + BoxWidth / 2, 0, min(1, BoxWidth/GetWidth(PO_ID)))
  5855.   if right(PO_Location, 1) == 'R' then call RightText(PO_ID, BoxLeft + BoxWidth - 2 * CurveOffset)
  5856.  
  5857.   return PO_ID
  5858. /**/
  5859.  
  5860. /***//*** PrintText (PT) ***/
  5861. PrintText:
  5862.   parse arg PT_Left, PT_Top, PT_FontType, PT_Style, PT_Color, PT_Width, PT_Text
  5863.  
  5864.   if upper(PT_Style) == 'N' then PT_Font = Font.PT_FontType
  5865.   else PT_Font = Bold.PT_FontType
  5866.  
  5867.   if App == 'FW' then do
  5868.     if left(PT_Text, 1) == '"' then PT_Text = '""'PT_Text
  5869.     PT_Top = PT_Top + TextAdj * Height.PT_FontType
  5870.     TEXTBLOCKTYPEPREFS SIZE FSize.PT_FontType WIDTH trunc(PT_Width) COLOR '"'PT_Color'"' FONT PT_Font
  5871.     DRAWTEXTBLOCK 1 trunc(PT_Left, 4) trunc(PT_Top, 4) PT_Text; PT_id = result
  5872.   end
  5873.   else if App == 'PGS' then do
  5874.     DRAWTEXTOBJ PT_Left PT_Top WINDOW winName; PT_id = result
  5875.     SELECTTEXT AT PT_Left PT_Top WINDOW winName
  5876.     BEGINCOMMANDCAPTURE
  5877.       SETLEADING RELATIVE 100
  5878.       SETTYPESIZE FSize.PT_FontType WINDOW winName
  5879.       SETTYPEWIDTH PT_Width WINDOW winName
  5880.       SETFONT PT_Font WINDOW winName
  5881.       SETCOLORSTYLE '"'PT_Color'"' COLORNUMBER 0 FILL TEXT WINDOW winName
  5882.     ENDCOMMANDCAPTURE
  5883.     if pos('"', PT_Text) > 0 then do
  5884.       call WriteFile(Storage'FWCTemp.txt', PT_Text)
  5885.       INSERTTEXT FILE '"'Storage'FWCTemp.txt"' FILTER ASCII WINDOW winName
  5886.     end
  5887.     else INSERT '"'PT_Text'"' WINDOW winName
  5888.   end
  5889.  
  5890.   return PT_id
  5891. /**/
  5892.  
  5893. /***//*** ProcessVariableList (PVL) ***/
  5894. ProcessVariableList:
  5895.   parse arg PVL_DataFile
  5896.  
  5897.   call openv(PVL_DataFile)
  5898.     do until eofv(PVL_DataFile)
  5899.       PVL_Ln = ReadVLn(PVL_DataFile)
  5900.       if PVL_Ln = '' then iterate /* Skip blank lines */
  5901.       PVL_VarName = strip(word(PVL_Ln, 1))
  5902.       PVL_UpperVarName = upper(PVL_VarName)
  5903.       PVL_VarStem = upper(left(PVL_VarName, pos('.', PVL_VarName)))
  5904.       VarNameMaxLn = max(VarNameMaxLn, length(PVL_VarName))
  5905.       if (pos('/* End Pass One', PVL_Ln) > 0) | (PVL_DoHighlights == 1) then do
  5906.         PVL_DoHighlights = 1
  5907.         if left(PVL_Ln, 2) == '/*' then iterate
  5908.         PVL_Month = left(PVL_Ln, 2)
  5909.         if upper(PVL_Month) == 'CA' then PVL_Month = 14
  5910.         MonthCount.PVL_Month = MonthCount.PVL_Month + 1
  5911.         PVL_MonthCount = MonthCount.PVL_Month
  5912.         HighlightData.PVL_Month.PVL_MonthCount = PVL_Ln
  5913.         iterate
  5914.       end
  5915.       if PVL_VarName == 'return' then leave
  5916.       if left(PVL_Ln, 2) == '/*' then iterate
  5917.       if PVL_VarStem == 'IMAGECLASS.' then do
  5918.         ImageClass.ImgClassCount = substr(PVL_VarName, 12)
  5919.         PVL_ImageFile = strip(substr(PVL_Ln, pos("=", PVL_Ln) + 1), 'B', " '"||'"')
  5920.         interpret "ImageFile."ImgClassCount" = PVL_ImageFile"
  5921.         ImgClassCount = ImgClassCount + 1
  5922.         iterate
  5923.       end
  5924.       interpret PVL_Ln
  5925.       if (PVL_VarStem == 'ALTCOLOR.') | (PVL_VarStem == 'BACKGROUND.') |,
  5926.          (PVL_VarStem == 'COLOR.') | (PVL_VarStem == 'LINE.') then do
  5927.         PVL_VariableType = 'Color'
  5928.         if (value(PVL_VarName) == '<'Clear$'>') & (PVL_VarStem ~= 'BACKGROUND.') then do
  5929.           call AddMsg('W', 'Only "Background." variables can be set to <'Clear$'>; 'ColorList.0' used instead.')
  5930.           interpret PVL_VarName' = 'ColorList.0
  5931.         end
  5932.         if (MemberID(value(PVL_VarName), 'ColorList') == -1) then do
  5933.           call AddMsg('W', value(PVL_VarName)' in "'PVL_Ln'"'" can't be found; "ColorList.0" used instead.")
  5934.           PVL_Ln = PVL_VarName' = "'ColorList.0'"'
  5935.         end
  5936.       end
  5937.       else if (PVL_VarStem == 'FONT.') | (PVL_VarStem == 'BOLD.') then PVL_VariableType = 'Font'
  5938.       else if upper(PVL_VarName) == 'DOHIDE' then PVL_VariableType = 'Misc'
  5939.       else if (PVL_VarStem == 'MARGIN.') | (upper(left(PVL_VarName, 2)) == 'DO') |,
  5940.               (upper(PVL_VarName) == 'ORIENTATION') then PVL_VariableType = 'Main'
  5941.       else PVL_VariableType = 'Misc'
  5942.       if (VariableSeq.PVL_UpperVarName == '') & (RD_VariableType == 'Default') then do
  5943.         VariableName.VariableCount = PVL_VarName
  5944.         VariableType.VariableCount = PVL_VariableType
  5945.         VariableSeq.PVL_UpperVarName = VariableCount
  5946.         VariableCount = VariableCount + 1
  5947.       end
  5948.     end
  5949.   call closev(PVL_DataFile)
  5950.  
  5951.   return
  5952. /**/
  5953.  
  5954. /***//*** QuoteIt (PROCEDURE) ***/
  5955. QuoteIt: PROCEDURE
  5956.   parse arg String
  5957.  
  5958.   String = strip(String)
  5959.   if (left(String, 1) == '"') & (right(String, 1) == '"') then return String
  5960.   else if (left(String, 1) == "'") & (right(String, 1) == "'") then return String
  5961.   else if pos("'", String) == 0 then return "'"String"'"
  5962.   else return '"'String'"'
  5963.  
  5964.   return
  5965. /**/
  5966.  
  5967. /***//*** ReadBrowserList (RBL) ***/
  5968. ReadBrowserList:
  5969.   parse arg RBL_FileHandle, RBL_GadIDList, RBL_ItemList, RBL_CurrentItem
  5970.  
  5971.   interpret 'RBL_AlreadyOpen = 'RBL_FileHandle
  5972.   if RBL_AlreadyOpen == 0 then do
  5973.     call ToPIPE(RBL_FileHandle, 'open')
  5974.     if RBL_FileHandle == 'MiscVarReq' then do
  5975.       do RBL_i = 0 to UpdateVarCmds - 1
  5976.         GadID = ToPIPE('MiscVarReq', UpdateVarCmd.RBL_i)
  5977.         interpret 'MiscVarGad.'GadID' = 'UpdateVarNum.RBL_i
  5978.       end
  5979.       UpdateVarCmds = 0
  5980.     end
  5981.     if RBL_CurrentItem ~= '' then call ToPIPE(RBL_FileHandle, 'id 1 s='MemberID(RBL_CurrentItem, RBL_ItemList) + 2)
  5982.     interpret RBL_FileHandle '= 1'
  5983.   end
  5984.   else do
  5985.     if RBL_FileHandle == 'MiscVarReq' then do
  5986.       do RBL_i = 0 to UpdateVarCmds - 1
  5987.         GadID = ToPIPE('MiscVarReq', UpdateVarCmd.RBL_i)
  5988.         interpret 'MiscVarGad.'GadID' = 'UpdateVarNum.RBL_i
  5989.       end
  5990.       UpdateVarCmds = 0
  5991.     end
  5992.     if RBL_CurrentItem ~= '' then call ToPIPE(RBL_FileHandle, 'id 1 s='MemberID(RBL_CurrentItem, RBL_ItemList) + 2)
  5993.     call ToPIPE(RBL_FileHandle, 'id 0 s=64')
  5994.   end
  5995.  
  5996.   do while ~eof(RBL_FileHandle)
  5997.     call ToPIPE(RBL_FileHandle, 'continue')
  5998.     RBL_Result = readln(RBL_FileHandle)
  5999.     parse var RBL_Result . . . . RBL_NodeID
  6000.     RBL_NodeID = strip(RBL_NodeID)
  6001.     interpret 'RBL_ListID = 'RBL_GadIDList'.RBL_NodeID'
  6002.     if pos('gadget', RBL_Result) > 0 then leave
  6003.   end
  6004.   call ToPIPE(RBL_FileHandle, 'id 0 s=128')
  6005.   interpret 'RBL_Entry = 'RBL_ItemList'.'RBL_ListID
  6006.   return RBL_Entry
  6007. /**/
  6008.  
  6009. /***//*** ReadCAGad (PROCEDURE) ***/
  6010. ReadCAGad: PROCEDURE
  6011.   parse arg PipeName, GadgetID
  6012.   call writeln(PipeName, 'id 'GadgetID' read')
  6013.   return readln(PipeName)
  6014. /**/
  6015.  
  6016. /***//*** ReadData (RD) ***/
  6017. ReadData:
  6018.   VariableCount    = 0
  6019.   MainVarCount     = 0
  6020.   MiscVarCount     = 0
  6021.   ColorVarCount    = 0
  6022.   FontVarCount     = 0
  6023.   ImgClassCount    = 0
  6024.   VariableName.    = ''
  6025.   VariableSeq.     = ''
  6026.   RD_Progress      = -1
  6027.   VarNameMaxLn     = 0
  6028.   MonthCount.      = 0
  6029.   PVL_DoHighlights = 0
  6030.   GadSel.          = 0
  6031.   GadDis.          = 0
  6032.   DSR_Sel.         = 0
  6033.   DSR_PSel.        = 0
  6034.   DSR_Dis.         = copies('0', PosnCount + 1)
  6035.   DSR_PDis.        = copies('0', PosnCount + 1)
  6036.  
  6037.   /* Read default variables */
  6038.   call open('Temp', FullCallPath)
  6039.     call seek('Temp', -5000, 'E')
  6040.     Chunk = readch('Temp', 65535)
  6041.     EndPos = pos('VarList:'||'0a'x, Chunk)
  6042.     if EndPos == 0 then do
  6043.       call AddMsg('E', 'Unable to locate default variables.')
  6044.       call CleanUp
  6045.     end
  6046.     RD_VariableFile = substr(Chunk, EndPos + 9)
  6047.   call close('Temp')
  6048.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  6049.   RD_VariableType = 'Default'
  6050.   call ProcessVariableList('RD_VariableFile')
  6051.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  6052.  
  6053.   if App == 'FW' then do
  6054.     GETSECTIONSETUP Top Bottom Inside Outside
  6055.     parse var result Margin.Top Margin.Bottom Margin.Left Margin.Right
  6056.   end
  6057.   else if App == 'PGS' then do
  6058.     Margin.Top    = 0.5
  6059.     Margin.Bottom = 0.5
  6060.     Margin.Left   = 0.5
  6061.     Margin.Right  = 0.5
  6062.   end
  6063.   do RD_i = 0 to VariableCount - 1
  6064.     Default.RD_i = value(VariableName.RD_i)
  6065.   end
  6066.  
  6067.   /* Read user variables */
  6068.   if PrefsFile ~= 'Default' then do
  6069.     RD_VariableFile = ReadFile(PrefsFile)
  6070.     RD_VariableType = 'User'
  6071.     if RD_VariableFile ~= '' then call ProcessVariableList('RD_VariableFile')
  6072.   end
  6073.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  6074.   if HostScreen ~= '' then AppScreen = HostScreen
  6075.  
  6076.   do RD_i = 0 to VariableCount - 1
  6077.     select
  6078.       when VariableType.RD_i == 'Color' then do
  6079.         ColorVarName.ColorVarCount = VariableName.RD_i
  6080.         ColorVarCount = ColorVarCount + 1
  6081.         if ClassAct == 1 then ColorVarList = ColorVarList''VariableName.RD_i'|'
  6082.       end
  6083.       when VariableType.RD_i == 'Font' then do
  6084.         FontVarName.FontVarCount = VariableName.RD_i
  6085.         FontVarCount = FontVarCount + 1
  6086.       end
  6087.       when VariableType.RD_i == 'Main' then do
  6088.         MainVarName.MainVarCount = VariableName.RD_i
  6089.         MainVarCount = MainVarCount + 1
  6090.       end
  6091.       otherwise do
  6092.         MiscVarName.MiscVarCount = VariableName.RD_i
  6093.         MiscVarCount = MiscVarCount + 1
  6094.         if ClassAct == 1 then MiscVarList = MiscVarList''VariableName.RD_i'|'
  6095.       end
  6096.     end
  6097.   end
  6098.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  6099.  
  6100.   if ImgClassCount > 0 then do
  6101.     do RD_i = 0 to ImgClassCount - 1
  6102.       MiscVarName.MiscVarCount = 'ImageClass.'ImageClass.RD_i
  6103.       MiscVarCount = MiscVarCount + 1
  6104.       if ClassAct == 1 then MiscVarList = MiscVarList''MiscVarName.MiscVarCount'|'
  6105.     end
  6106.   end
  6107.  
  6108.   MainVarName.COUNT  = MainVarCount
  6109.   MiscVarName.COUNT  = MiscVarCount
  6110.   ColorVarName.COUNT = ColorVarCount
  6111.   FontVarName.COUNT  = FontVarCount
  6112.   ImageClass.COUNT   = ImgClassCount
  6113.  
  6114.   CurrentColorName   = ColorVarName.0
  6115.   CurrentFontName    = FontVarName.0
  6116.   CurrentMiscName    = MiscVarName.0
  6117.   if upper(left(CurrentMiscName, 11)) == 'IMAGECLASS.' then do
  6118.     IC = MemberID(upper(substr(CurrentMiscName, 12)), 'ImageClass')
  6119.     VarVal = ImageFile.IC
  6120.   end
  6121.   else VarVal = Value(CurrentMiscName)
  6122.  
  6123.   if upper(Orientation) == 'WIDE' then OrientChoice = 0
  6124.   else OrientChoice = 1
  6125.  
  6126.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  6127.   if (exists(SunCalcPath'suncalc')) & (~exists(Storage'suncalc')) then address command 'copy 'SunCalcPath'suncalc 'Storage
  6128.  
  6129.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  6130.   if (exists(GfxAppPath''GfxApp)) & (~exists(Storage''GfxApp)) then address command 'copy 'GfxAppPath''GfxApp' 'Storage
  6131.   if ~exists(Storage''GfxApp) then do
  6132.     GfxDisable = 1
  6133.     DoImages = 0
  6134.   end
  6135.   else GfxDisable = 0
  6136.  
  6137.   if PhaseLib ~= 1 then DoPhases = 0
  6138.  
  6139.   do i = 0 to 6
  6140.     val = i - StartWeek
  6141.     if val < 0 then val = 7 + val
  6142.     interpret 'Day.'D.i '=' val
  6143.     interpret 'Day.val = 'D.i'$'
  6144.   end
  6145.   return
  6146. /**/
  6147.  
  6148. /***//*** ReadFile (PROCEDURE) ***/
  6149. ReadFile: PROCEDURE
  6150.   parse arg file
  6151.  
  6152.   if open('Temp', file) then do
  6153.     val = strip(readch('Temp', 65535), 'B', ' '||'0a'x)
  6154.     call close('Temp')
  6155.   end
  6156.   else val = ''
  6157.   return val
  6158. /**/
  6159.  
  6160. /***//*** ReadToEOL (PROCEDURE) ***/
  6161. ReadToEOL: PROCEDURE
  6162.   parse arg Start, Var
  6163.  
  6164.   if Start == 0 then return ''
  6165.  
  6166.   EOL = pos('0a'x, Var, Start)
  6167.   if EOL == 0 then EOL = length(Var) + 1
  6168.  
  6169.   return substr(Var, Start, EOL - Start)
  6170. /**/
  6171.  
  6172. /***//*** ReplaceString (RS) ***/
  6173. ReplaceString: PROCEDURE
  6174.   parse arg old, new, string
  6175.  
  6176.   if pos(old, string) > 0 then do
  6177.     parse var string begin(old)end
  6178.     return begin || new || ReplaceString(old, new, end)
  6179.   end
  6180.  
  6181.   return string
  6182. /**/
  6183.  
  6184. /***//*** RightText (RT) ***/
  6185. RightText:
  6186.   parse arg RT_id, RT_RightEdge
  6187.  
  6188.   if App = 'FW' then do
  6189.     GETOBJECTCOORDS RT_id; Parse Var result . . RT_Text.Bottom RT_Text.Width RT_Text.Height
  6190.     RT_Text.Left = RT_RightEdge - RT_Text.Width
  6191.     SETOBJECTCOORDS RT_id 1 RT_Text.Left RT_Text.Bottom RT_Text.Width RT_Text.Height
  6192.   end
  6193.   else if App == 'PGS' then do
  6194.     GETTEXTOBJ POSITION RT_Text OBJECTID RT_id WINDOW winName
  6195.     RT_Text.Width = RT_Text.Right - RT_Text.Left
  6196.     RT_Text.Left = RT_RightEdge - RT_Text.Width
  6197.     EDITTEXTOBJ POSITION RT_Text.Left RT_Text.Top (RT_Text.Left + RT_Text.Width) RT_Text.Bottom OBJECTID RT_id WINDOW winName
  6198.   end
  6199.   return RT_id
  6200. /**/
  6201.  
  6202. /***//*** SaveVariable (SV) ***/
  6203. SaveVariable:
  6204.   parse arg SV_OutFile, SV_Variable, SV_Value
  6205.  
  6206.   SV_Cmd = SV_Variable' = 'SV_Value
  6207.   call WriteLn(SV_OutFile, SV_Cmd)
  6208.   interpret SV_Cmd
  6209.  
  6210.   return
  6211. /**/
  6212.  
  6213. /***//*** SetFill (SF) ***/
  6214. SetFill:
  6215.   parse arg SF_ID, SF_StrokeColor, SF_FillColor
  6216.  
  6217.   BEGINCOMMANDCAPTURE
  6218.     SETSTROKEWEIGHT '0.3pt' STROKENUMBER 0 OBJECT OBJECTID SF_ID WINDOW winName
  6219.     SETCOLORSTYLE '"'SF_StrokeColor'"' STROKENUMBER 0 OBJECT OBJECTID SF_ID WINDOW winName
  6220.     FILLED 'ON'
  6221.     SETCOLORSTYLE '"'SF_FillColor'"' FILL OBJECT OBJECTID SF_ID WINDOW winName
  6222.   ENDCOMMANDCAPTURE
  6223.   return
  6224. /**/
  6225.  
  6226. /***//*** SetHighlights (SH) ***/
  6227. SetHighlights:
  6228. /* The algorithm for calculating Easter is due to J.-M. Oudin (1940) and is        */
  6229. /* reprinted in the Explanatory Supplement to the Astronomical Almanac, ed. P. K.  */
  6230. /* Seidelmann (1992). See Chapter 12, "Calendars", by L. E. Doggett.               */
  6231. /*                                                                                 */
  6232. /* I obtained the algorithm from the US Naval Observatory web site                 */
  6233.  
  6234.   SettingHighlights = 1
  6235.   if EasterKnown ~= 1 then do
  6236.     SH_century = trunc(Year / 100)
  6237.     SH_n = trunc(Year - 19 * trunc(Year / 19))
  6238.     SH_k = trunc((SH_century - 17) / 25)
  6239.     SH_i = SH_century - trunc(SH_century / 4) - trunc((SH_century - SH_k) / 3) + 19 * SH_n + 15
  6240.     SH_i = SH_i - 30 * trunc(SH_i / 30)
  6241.     SH_i = SH_i - trunc(SH_i / 28) * (1 - trunc(SH_i / 28) * trunc(29 / (SH_i + 1)) * trunc((21 - SH_n) / 11))
  6242.     SH_j = Year + trunc(Year / 4) + SH_i + 2 - SH_century + trunc(SH_century / 4)
  6243.     SH_j = SH_j - 7 * trunc(SH_j / 7)
  6244.     SH_l = SH_i - SH_j
  6245.     SH_EasterMonth  = 3 + trunc((SH_l + 40 ) / 44)
  6246.     SH_EasterDay    = SH_l + 28 - 31 * trunc(SH_EasterMonth / 4)
  6247.     EasterSerial = DateInfo('I', Year'0'SH_EasterMonth''right(SH_EasterDay, 2, '0'), 'S')
  6248.     EasterKnown  = 1
  6249.   end
  6250.   Highlight. = ''
  6251.   Image.     = ''
  6252.  
  6253.   if PrefsFile ~= 'Default' then do
  6254.     call open('DataFile', PrefsFile)
  6255.     do forever
  6256.       if eof('DataFile') then leave
  6257.       if pos('/* End Pass One', readln('DataFile')) > 0 then do
  6258.         do until eof('DataFile')
  6259.           SH_Ln = strip(ReadLn('DataFile'))
  6260.           if right(SH_Ln, 2) == '*/' then SH_Ln = left(SH_Ln, lastpos('/*', SH_Ln) - 1)
  6261.           SH_Ln2 = left(SH_Ln, 2)
  6262.           if upper(left(SH_Ln, 14)) == 'CALCULATEEDATE' then interpret 'call 'SH_Ln
  6263.           if (SH_Ln2 == Mn) | (SH_Ln2 == '13') then do
  6264.             select
  6265.               when upper(substr(SH_Ln, 3, 13)) == 'CALCULATEDATE' then interpret 'call 'substr(SH_Ln, 3)
  6266.               when upper(substr(SH_Ln, 3, 9)) == 'HIGHLIGHT' then call AssignHighlight(substr(SH_Ln, 3))
  6267.               when upper(substr(SH_Ln, 3, 5)) == 'IMAGE' then call AssignImage(substr(SH_Ln, 3))
  6268.               when upper(substr(SH_Ln, 3, 14)) == 'CALCULATEIMAGE' then interpret 'call 'substr(SH_Ln, 3)
  6269.               otherwise do
  6270.                 call AddMsg('W', 'Check the keyword in the following line of your preferences file:')
  6271.                 call AddMsg('W', '  'SH_Ln)
  6272.                 ListHighlightData = 1
  6273.               end
  6274.             end
  6275.           end
  6276.         end
  6277.       end
  6278.     end
  6279.     call close('DataFile')
  6280.   end
  6281.  
  6282.   SettingHighlights = 0
  6283. return
  6284. /**/
  6285.  
  6286. /***//*** Syntax () ***/
  6287. Syntax:
  6288.   if DoingCleanup == 1 then return
  6289.   signal off syntax
  6290.  
  6291.   ErrorLine  = SIGL
  6292.   SourceLine = strip(SourceLine(ErrorLine))
  6293.  
  6294.   call AddMsg('E', 'Error 'RC' ('errortext(RC)')')
  6295.   call AddMsg('E', 'Line 'ErrorLine': 'SourceLine)
  6296.   call AddMsg('E', ParseVariables(SourceLine))
  6297.  
  6298.   call Cleanup
  6299.   exit
  6300. /**/
  6301.  
  6302. /***//*** ToPIPE (TP) ***/
  6303. ToPIPE:
  6304.   parse arg PipeName, TP_CMD
  6305.  
  6306.   call writeln(PipeName,' 'TP_CMD)
  6307.   TP_Response=readln(PipeName)
  6308.  
  6309.   parse var TP_Response TP_Response1 TP_Response2 .
  6310.  
  6311.   if TP_Response1 == 'ok' then return(TP_Response2)
  6312.   if TP_Response == '' then TP_Response = 'Blank line'
  6313.   call AddMsg('E', 'Line : 'SIGL)
  6314.   call AddMsg('E', PipeName' error: 'TP_Response)
  6315.   call AddMsg('E', 'Returned from: 'TP_CMD)
  6316.   call Cleanup
  6317. /**/
  6318.  
  6319. /***//*** VIO Routines () ***/
  6320. /***//** OpenV() **/
  6321. OpenV:
  6322.   parse arg VIO_Variable
  6323.  
  6324.   if Open.VIO_Variable ~= 1 then do
  6325.     if symbol(VIO_Variable) == 'LIT' then interpret VIO_Variable' = ""'
  6326.     Open.VIO_Variable = 1
  6327.     Pointer.VIO_Variable = 1
  6328.     EOF.VIO_Variable = 0
  6329.     return 1
  6330.   end
  6331.   else return 0
  6332. /**/
  6333.  
  6334. /***//** CloseV() **/
  6335. CloseV:
  6336.   parse arg VIO_Variable
  6337.  
  6338.   If Open.VIO_Variable == 0 then return 0
  6339.   Open.VIO_Variable = 0
  6340.   return 1
  6341. /**/
  6342.  
  6343. /***//** SeekV() **/
  6344. SeekV:
  6345.   parse arg VIO_Variable, VIO_Offset, VIO_Anchor
  6346.  
  6347.   if Open.VIO_Variable == 1 then do
  6348.     VIO_Anchor = upper(left(VIO_Anchor, 1))
  6349.  
  6350.     VIO_Value = Value(VIO_Variable)
  6351.     select
  6352.       when VIO_Anchor == 'B' then Pointer.VIO_Variable = VIO_Offset
  6353.       when VIO_Anchor == 'E' then Pointer.VIO_Variable = length(VIO_Value) + VIO_Offset
  6354.       otherwise Pointer.VIO_Variable = Pointer.VIO_Variable + VIO_Offset
  6355.     end
  6356.  
  6357.     if Pointer.VIO_Variable > length(VIO_Value) then Pointer.VIO_Variable = length(VIO_Value) + 1
  6358.     if Pointer.VIO_Variable == 0 then Pointer.VIO_Variable = 1
  6359.     return Pointer.VIO_Variable
  6360.   end
  6361.   else return 0
  6362. /**/
  6363.  
  6364. /***//** ReadVCh() **/
  6365. ReadVCh:
  6366.   parse arg VIO_Variable, VIO_Length
  6367.  
  6368.   if VIO_Length == '' then VIO_Length = 1
  6369.   if Open.VIO_Variable == 1 then do
  6370.     if EOF.VIO_Variable == 0 then do
  6371.       VIO_Value = Value(VIO_Variable)
  6372.       VIO_Length = min(VIO_Length, length(VIO_Value) - Pointer.VIO_Variable)
  6373.       VIO_Ret = substr(VIO_Value, Pointer.VIO_Variable, VIO_Length)
  6374.       Pointer.VIO_Variable = Pointer.VIO_Variable + VIO_Length
  6375.       if Pointer.VIO_Variable > length(VIO_Value) then EOF.VIO_Variable = 1
  6376.       else EOF.VIO_Variable = 0
  6377.     end
  6378.     else VIO_Ret = ''
  6379.   end
  6380.   else VIO_Ret = ''
  6381.  
  6382.   return VIO_Ret
  6383. /**/
  6384.  
  6385. /***//** ReadVLn(RV) **/
  6386. ReadVLn:
  6387.   parse arg VIO_Variable, VIO_Count, VIO_SepChar
  6388.  
  6389.   if VIO_Count == '' then VIO_Count = 1
  6390.   if VIO_SepChar == '' then VIO_SepChar = '0a'x
  6391.  
  6392.   if Open.VIO_Variable == 1 then do
  6393.     VIO_Value = Value(VIO_Variable)
  6394.     VIO_Ret   = ''
  6395.     do VIO_i = 1 to VIO_Count
  6396.       VIO_LF = pos('0a'x, VIO_Value, Pointer.VIO_Variable)
  6397.       if VIO_LF > 0 then do
  6398.         VIO_Ret = VIO_Ret''substr(VIO_Value, Pointer.VIO_Variable, VIO_LF - Pointer.VIO_Variable)
  6399.         Pointer.VIO_Variable = VIO_LF + 1
  6400.         if VIO_LF = length(VIO_Value) then EOF.VIO_Variable = 1
  6401.         else EOF.VIO_Variable = 0
  6402.       end
  6403.       else do
  6404.         if Pointer.VIO_Variable < length(VIO_Value) then do
  6405.           VIO_Ret = VIO_Ret''substr(VIO_Value, Pointer.VIO_Variable)
  6406.           Pointer.VIO_Variable = length(VIO_Value) + 1
  6407.           EOF.VIO_Variable = 1
  6408.         end
  6409.       end
  6410.       if EOF.VIO_Variable == 1 then leave
  6411.       if VIO_i ~= VIO_Count then VIO_Ret = VIO_Ret''VIO_SepChar
  6412.     end
  6413.   end
  6414.   else VIO_Ret = ''
  6415.  
  6416.   return VIO_Ret
  6417. /**/
  6418.  
  6419. /***//** WriteVCh() **/
  6420. WriteVCh:
  6421.   parse arg VIO_Variable, VIO_String, VIO_Option
  6422.  
  6423.   VIO_Value  = Value(VIO_Variable)
  6424.   VIO_Option = upper(left(VIO_Option, 1))
  6425.   VIO_Length = length(VIO_Value)
  6426.   if VIO_Option == 'C' then do
  6427.     VIO_Value = Insert(VIO_String, VIO_Value, Pointer.VIO_Variable - 1)
  6428.     Pointer.VIO_Variable = Pointer.VIO_Variable + length(VIO_String)
  6429.   end
  6430.   else if VIO_Option == 'B' then do
  6431.     VIO_Value = VIO_String''VIO_Value
  6432.     Pointer.VIO_Variable = length(VIO_String) + 1
  6433.   end
  6434.   else do
  6435.     VIO_Value = VIO_Value''VIO_String
  6436.     Pointer.VIO_Variable = length(VIO_Value)
  6437.   end
  6438.   interpret VIO_Variable'= VIO_Value'
  6439.   if length(VIO_Value) = VIO_Length + length(VIO_String) then VIO_Ret = length(VIO_String)
  6440.   else VIO_Ret = 0
  6441.  
  6442.   return VIO_Ret
  6443. /**/
  6444.  
  6445. /***//** WriteVLn() **/
  6446. WriteVLn:
  6447.   parse arg VIO_Variable, VIO_String, VIO_Option
  6448.  
  6449.   return WriteVCh(VIO_Variable, VIO_String||'0a'x, VIO_Option)
  6450. /**/
  6451.  
  6452. /***//** EOFV() **/
  6453. EOFV:
  6454.   parse arg VIO_Variable
  6455.  
  6456.   if Open.VIO_Variable == 1 then return EOF.VIO_Variable
  6457.   else return 1
  6458. /**/
  6459. /**/
  6460.  
  6461. /***//*** WriteData (WD) ***/
  6462. WriteData:
  6463.   WD_FileOpen      = 0
  6464.   WD_MsgWritten    = 0
  6465.   WD_SepWritten    = 0
  6466.  
  6467.   /* Write non-imageclass variables */
  6468.   do WD_i = 0 to VariableCount - 1
  6469.     if value(VariableName.WD_i) ~= Default.WD_i then do
  6470.       WD_Value = Value(VariableName.WD_i)
  6471.       if (datatype(WD_Value) == 'CHAR') then do
  6472.         if pos("'", WD_Value) ~= 0 then WD_Value = '"'WD_Value'"'
  6473.         else WD_Value = "'"WD_Value"'"
  6474.       end
  6475.       call WriteDataLine(VariableName.WD_i' = 'WD_Value)
  6476.     end
  6477.   end
  6478.  
  6479.   /* Write imageclass variables */
  6480.   do WD_i = 0 to ImgClassCount - 1
  6481.     if ImageFile.WD_i ~= ScriptDir'Images/' then call WriteDataLine('ImageClass.'ImageClass.WD_i' = 'QuoteIt(ImageFile.WD_i))
  6482.   end
  6483.  
  6484.   /* Write highlight variables */
  6485.   do WD_i = 1 to 14
  6486.     WD_Month = right(WD_i, 2, '0')
  6487.     WD_MonthCount = MonthCount.WD_Month
  6488.     if WD_MonthCount > 0 then do
  6489.       do WD_j = 1 to WD_MonthCount
  6490.         if symbol('HighlightData.WD_Month.WD_j') == 'VAR' then do
  6491.           if WD_SepWritten == 0 then do
  6492.             call WriteDataLine('/* End Pass One - DO NOT DELETE THIS LINE!!! */')
  6493.             WD_SepWritten = 1
  6494.           end
  6495.           call WriteDataLine(HighlightData.WD_Month.WD_j)
  6496.         end
  6497.       end
  6498.     end
  6499.   end
  6500.  
  6501.   call close('DataFile')
  6502.  
  6503.   return
  6504.  
  6505. WriteDataLine:
  6506.   parse arg WDL_Data
  6507.  
  6508.   if WD_FileOpen == 0 then do
  6509.     if PrefsFile == 'Default' then do
  6510.       if ClassAct == 1 then WDL_File = CAGetFile('CA', GetFileDataGad, SelectPrefs$, ScriptDir'FWCalendar.prefs')
  6511.       else WDL_File = bguifilereq(ScriptDir'FWCalendar.prefs', SelectPrefs$)
  6512.       if WDL_File ~= '' then do
  6513.         WD_FileOpen = open('DataFile', WDL_File, 'W')
  6514.         if WD_FileOpen ~= 0 then do
  6515.           PrefsFile = WDL_File
  6516.           call WriteFile('ENV:FWCalendar', PrefsFile, 'B')
  6517.         end
  6518.         else call AddMsg('W', "Couldn't open selected data file ("WDL_File")")
  6519.       end
  6520.     end
  6521.     else WD_FileOpen = open('DataFile', PrefsFile, 'W')
  6522.     if WD_FileOpen ~= 0 then call writeln('DataFile', '/* Dataversion 'word(sourceline(4), 3)' */')
  6523.   end
  6524.   if WD_FileOpen ~= 0 then call writeln('DataFile', WDL_Data)
  6525.   else do
  6526.     if WD_MsgWritten == 0 then do
  6527.       WD_MsgWritten = 1
  6528.       call AddMsg('W', 'Unable to write to preference file.')
  6529.     end
  6530.   end
  6531.   return
  6532. /**/
  6533.  
  6534. /***//*** WriteFile (PROCEDURE) ***/
  6535. WriteFile: PROCEDURE
  6536.   parse arg file, var, which
  6537.  
  6538.   if open('Temp', file, 'W') then do
  6539.     success = writech('Temp', var)
  6540.     call close('Temp')
  6541.   end
  6542.   if (upper(which) == 'B') & (upper(left(file, 4)) == 'ENV:') then call WriteFile('ENVARC:'substr(file, 5), var)
  6543.  
  6544.   return success
  6545. /**/
  6546.  
  6547. /***//*** InitializeVariables (IV) ***/
  6548. InitializeVariables:
  6549.   esc               = "1B"x
  6550.   FSize.            = 10
  6551.   GenCalCount       = 22
  6552.   HighlightCount    = 0
  6553.   ImageCount        = 0
  6554.   ImageHeight.      = 0
  6555.   ImageType.        = ''
  6556.   ImageWidth.       = 0
  6557.   MoonPhase.        = ''
  6558.   UserPrefs         = ''
  6559.   Width.            = 100
  6560.   Spc               =' '
  6561.   NormalWidth.Spc   = 0
  6562.   BoldWidth.Spc     = 0
  6563.   ColorW            = 80
  6564.   ColorH            = 10
  6565.  
  6566.   PGSFilter.     = ''
  6567.   PGSFilter.ILBM = 'IFFILBM'
  6568.   PGSFilter.JFIF = 'JPEG'
  6569.   PGSFilter.POST = 'IllustratorEPS'
  6570.  
  6571.   GfxCmd.Visage      = '%s info'
  6572.   GfxTemplate.Visage = '. "0a"x . ImgDT ImgWidth "x" ImgHeight "x" .'
  6573.  
  6574.   GfxCmd.ImageDTInfo      = '%s'
  6575.   GfxTemplate.ImageDTInfo = 'ImgDT "-" ImgWidth "x" ImgHeight "x" .'
  6576.  
  6577.   GfxCmd.PicSize      = '%s "%t %w %h"'
  6578.   GfxTemplate.PicSize = 'ImgDT ImgWidth ImgHeight "0a"x'
  6579.  
  6580.   GroupCount     = 4
  6581.  
  6582.   PhasesPosn     = 1
  6583.   WeeknumberPosn = 2
  6584.   JulianPosn     = 3
  6585.   JulianLeftPosn = 4
  6586.   BothJPosn      = 5
  6587.   SunrisePosn    = 6
  6588.   SunsetPosn     = 7
  6589.   BothSPosn      = 8
  6590.   HistoryPosn    = 9
  6591.   RandomPosn     = 10
  6592.   PosnCount      = 10
  6593.  
  6594.   MXPair.1       = '11111 0011000000 0000100000'
  6595.   MXPair.2       = '11111 0000011000 0000000100'
  6596.   MXPair.3       = '11100 1111111100 0000000011'
  6597.   MXPairCount    = 3
  6598.  
  6599.   Do.1  = 'Phases'
  6600.   Do.2  = 'Weeknumber'
  6601.   Do.3  = 'Julian'
  6602.   Do.4  = 'JulianLeft'
  6603.   Do.5  = 'BothJ'
  6604.   Do.6  = 'Sunrise'
  6605.   Do.7  = 'Sunset'
  6606.   Do.8  = 'BothS'
  6607.   Do.9  = 'History'
  6608.   Do.10 = 'Random'
  6609.  
  6610.   if App == 'FW' then do
  6611.     DefaultFont = 'SoftSans'
  6612.     DefaultBold = 'SoftSans_Bold'
  6613.   end
  6614.   else if App == 'PGS' then do
  6615.     DefaultFont = 'PageStream-Normal'
  6616.     DefaultBold = 'PageStream-Normal'
  6617.   end
  6618.  
  6619.   Date      = 0
  6620.   Weekday   = 1
  6621.   Header    = 2
  6622.   MiniCal   = 3
  6623.   FYMiniCal = 4
  6624.   Highlight = 5
  6625.   Extras    = 6
  6626.   SubHeader = 7
  6627.   FontTypes = 7
  6628.  
  6629.   D.0 = 'Sunday'
  6630.   D.1 = 'Monday'
  6631.   D.2 = 'Tuesday'
  6632.   D.3 = 'Wednesday'
  6633.   D.4 = 'Thursday'
  6634.   D.5 = 'Friday'
  6635.   D.6 = 'Saturday'
  6636.  
  6637.   MonthLength.1  = 31
  6638.   MonthLength.2  = 28
  6639.   MonthLength.3  = 31
  6640.   MonthLength.4  = 30
  6641.   MonthLength.5  = 31
  6642.   MonthLength.6  = 30
  6643.   MonthLength.7  = 31
  6644.   MonthLength.8  = 31
  6645.   MonthLength.9  = 30
  6646.   MonthLength.10 = 31
  6647.   MonthLength.11 = 30
  6648.   MonthLength.12 = 31
  6649.  
  6650.   Month.1  = January$
  6651.   Month.2  = February$
  6652.   Month.3  = March$
  6653.   Month.4  = April$
  6654.   Month.5  = May$
  6655.   Month.6  = June$
  6656.   Month.7  = July$
  6657.   Month.8  = August$
  6658.   Month.9  = September$
  6659.   Month.10 = October$
  6660.   Month.11 = November$
  6661.   Month.12 = December$
  6662.  
  6663.   return
  6664. /**/
  6665.  
  6666. /***//*** SetVariables ***/
  6667. SetVariables:
  6668.   CNotice     = 'Created w/ FWCalendar © Ron Goertz'
  6669.   FSize.4pt   = 4
  6670.   Font.4pt    = DefaultFont
  6671.  
  6672.   DoJulian       = upper(DoJulian)
  6673.   DoJulianLeft   = upper(DoJulianLeft)
  6674.   CalendarBorder = CalendarBorder / 100
  6675.   CalendarShadow = CalendarShadow / 100
  6676.   CornerRadius   = CornerRadius / 100
  6677.   DateOffset     = DateOffset / 100
  6678.   HeaderLoc      = HeaderLoc / 100
  6679.   HeaderSize     = HeaderSize / 100
  6680.   MagnifyExtras  = MagnifyExtras / 100
  6681.   MaxImgHeight   = MaxImgHeight / 100
  6682.   MaxImgWidth    = MaxImgWidth / 100
  6683.   MiniCalHeight  = MiniCalHeight / 100
  6684.   MiniCalWidth   = MiniCalWidth / 100
  6685.   MoonRadius     = MoonRadius / 100
  6686.   ShiftLMini     = ShiftLMini / 720
  6687.   ShiftRMini     = ShiftRMini / 720
  6688.   StretchDateH   = StretchDateH / 100
  6689.   StretchDateW   = StretchDateW / 100
  6690.   SubHeaderLoc   = SubHeaderLoc / 100
  6691.   SubHeaderSize  = SubHeaderSize / 100
  6692.   TextAdj        = TextAdj / 100
  6693.   TTextArea      = TTextArea / 100
  6694.   WeekdaySize    = WeekdaySize / 100
  6695.   WTextArea      = WTextArea / 100
  6696.  
  6697.   if (PhaseLib ~= 1) & (DoPhases ~= 0) then do
  6698.     call AddMsg('W', 'date.library or rexxmathlib.library are required to calculate the moon phases.')
  6699.     DoPhases = 0
  6700.   end
  6701.  
  6702.   if App == 'FW' then do
  6703.     TextBase = TextAdj
  6704.     do i = 0 to FontTypes
  6705.       if Font.i == FilePart(Font.i) then Font.i = CurrentDir'FWFonts/SWOLFonts/'Font.i
  6706.       if ~exists(Font.i) then do
  6707.         call AddMsg('W', FilePart(Font.i)" can't be found; "DefaultFont" used instead.")
  6708.         Font.i = DefaultFont
  6709.       end
  6710.     end
  6711.     if Bold.MiniCal == FilePart(Bold.MiniCal) then Bold.MiniCal = CurrentDir'FWFonts/SWOLFonts/'Bold.MiniCal
  6712.     if ~exists(Bold.MiniCal) then do
  6713.       call AddMsg('W', FilePart(Bold.MiniCal)" can't be found; "DefaultBold" used instead.")
  6714.       Bold.MiniCal = DefaultBold
  6715.     end
  6716.     if Bold.FYMiniCal == FilePart(Bold.FYMiniCal) then Bold.FYMiniCal = CurrentDir'FWFonts/SWOLFonts/'Bold.FYMiniCal
  6717.     if ~exists(Bold.FYMiniCal) then do
  6718.       call AddMsg('W', FilePart(Bold.FYMiniCal)" can't be found; "DefaultBold" used instead.")
  6719.       Bold.FYMiniCal = DefaultBold
  6720.     end
  6721.     PAGESETUP ORIENT Orientation
  6722.     if upper(Orientation) == 'WIDE' then TextArea = WTextArea
  6723.     else TextArea = TTextArea
  6724.  
  6725.     GETDISPLAYPREFS Measure; UserPrefs = 'DISPLAYPREFS Measure 'result
  6726.     DISPLAYPREFS Measure Inches
  6727.     SECTIONSETUP TOP Margin.Top BOTTOM Margin.Bottom INSIDE Margin.Left OUTSIDE Margin.Right
  6728.     GETPAGESETUP Width Height
  6729.     parse var result FullWidth FullHeight
  6730.   end
  6731.   else if App = 'PGS' then do
  6732.     TextBase = 1
  6733.     do i = 0 to FontTypes
  6734.       do j = 0 to FontList.COUNT - 1
  6735.         if upper(Font.i) == upper(FontList.j) then leave
  6736.       end
  6737.       if j == FontList.COUNT then do
  6738.         call AddMsg('W', Font.i" can't be found; "DefaultFont" used instead.")
  6739.         Font.i = DefaultFont
  6740.       end
  6741.     end
  6742.     do j = 0 to FontList.COUNT - 1
  6743.       if upper(Bold.MiniCal) == upper(FontList.j) then leave
  6744.     end
  6745.     if j == FontList.COUNT then do
  6746.       call AddMsg('W', Bold.MiniCal" can't be found; "DefaultBold" used instead.")
  6747.       Bold.MiniCal = DefaultBold
  6748.     end
  6749.     do j = 0 to FontList.COUNT - 1
  6750.       if upper(Bold.FYMiniCal) == upper(FontList.j) then leave
  6751.     end
  6752.     if j == FontList.COUNT then do
  6753.       call AddMsg('W', Bold.FYMiniCal" can't be found; "DefaultBold" used instead.")
  6754.       Bold.FYMiniCal = DefaultBold
  6755.     end
  6756.  
  6757.     if upper(Orientation) == 'WIDE' then do
  6758.       TextArea = WTextArea
  6759.       Orientation = 'LANDSCAPE'
  6760.     end
  6761.     else do
  6762.       TextArea = TTextArea
  6763.       Orientation = 'PORTRAIT'
  6764.     end
  6765.  
  6766.     if CalType == 1 then DocName = '"'EnteredYear''Mn''Calendar$'"'
  6767.     else if CalType == 2 then DocName = '"'EnteredYear''Calendars$'"'
  6768.     else DocName = '"'EnteredYear''Calendar$'"'
  6769.     PageName = '"FWCalendar by Ron Goertz"'
  6770.     NEWDOCUMENT DocName
  6771.     NEWMASTERPAGE PageName PageWidth PageHeight SINGLE Orientation
  6772.     SETMARGINGUIDES Margin.Left Margin.Right Margin.Top Margin.Bottom MASTERPAGE PageName
  6773.     SETDIMENSIONS PageWidth PageHeight SINGLE Orientation MASTERPAGE PageName
  6774.     SETCOLUMNGUIDES 0 0 MASTERPAGE PageName
  6775.     SETDOCUMENTSTATUS unchanged DOCUMENT DocName
  6776.     OPENWINDOW '"View 1"' DOCUMENT DocName PAGE 1
  6777.     GETMEASUREMENTS COORDINATE stemc RELATIVE rel TEXT tex FROM fro
  6778.     UserPrefs = 'SETMEASUREMENTS COORDINATE 'stemc.horizontal stemc.vertical' RELATIVE 'rel' TEXT 'tex' FROM 'fro
  6779.     SETMEASUREMENTS COORDINATE Inches Sameas RELATIVE Sameas TEXT Points FROM Page
  6780.     GETMARGINGUIDES temp MASTERPAGE PageName
  6781.     if rc == 0 then do
  6782.       Margin.Left   = temp.inside
  6783.       Margin.Right  = temp.outside
  6784.       Margin.Top    = temp.top
  6785.       Margin.Bottom = temp.bottom
  6786.     end
  6787.     GETDIMENSIONS temp MASTERPAGE PageName
  6788.     CmdSuccess = rc
  6789.     if Orientation = 'LANDSCAPE' then do
  6790.       if CmdSuccess == 0 then do
  6791.         FullWidth  = temp.height
  6792.         FullHeight = temp.width
  6793.       end
  6794.       else do
  6795.         FullWidth  = PageHeight
  6796.         FullHeight = PageWidth
  6797.       end
  6798.     end
  6799.     else do
  6800.       if CmdSuccess == 0 then do
  6801.         FullWidth  = temp.width
  6802.         FullHeight = temp.height
  6803.       end
  6804.       else do
  6805.         FullWidth  = PageWidth
  6806.         FullHeight = PageHeight
  6807.       end
  6808.     end
  6809.     CURRENTWINDOW; winName = '"'RESULT'"'
  6810.   end
  6811.  
  6812.   if App == 'FW' then do
  6813.     VIEW 20
  6814.   end
  6815.   else if App == 'PGS' then do
  6816.     if DoHide == 1 then HIDEWINDOW
  6817.     else DISPLAY SCALE 25
  6818.     REFRESH OFF
  6819.   end
  6820.  
  6821.   if CalType == 1 then do
  6822.     EventCount = GenCalCount + MonthLength.Month + DoMiniCals * (MonthLength.NextMonth + MonthLength.PrevMonth + 4)
  6823.     Gen$ = BuildString(GeneratingM$, GenMVars)
  6824.   end
  6825.   else if CalType == 2 then do
  6826.     if EndMonth < Month then EndMonth = EndMonth + 12
  6827.     MonthCount = EndMonth - Month + 1
  6828.     EventCount = 7 + (MonthCount * 54) + DoMiniCals * (MonthCount * 62)
  6829.     Gen$ = BuildString(GeneratingY$, GenYVars)
  6830.   end
  6831.   else do
  6832.     EventCount = 365 + 24
  6833.     Gen$ = BuildString(GeneratingY$, GenYVars)
  6834.   end
  6835.   Req = OpenBusy(Gen$, EventCount)
  6836.  
  6837.   PrintWidth  = FullWidth - Margin.Left - Margin.Right
  6838.   PrintHeight = FullHeight - Margin.Top - Margin.Bottom
  6839.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  6840.  
  6841.   if CalType < 3 then do
  6842.     Height.4pt = GetHeight(4pt)
  6843.  
  6844.     if ((PrintHeight - Height.4pt - (TextArea * PrintHeight))/5 * 8) >= 4 then do
  6845.       DoCopyright = 1
  6846.       PrintHeight = PrintHeight - Height.4pt
  6847.     end
  6848.     else DoCopyright = 0
  6849.  
  6850.     CalendarBorder  = CalendarBorder * PrintWidth
  6851.     CalendarShadow  = CalendarShadow * PrintWidth
  6852.     PrintWidth      = PrintWidth - 2 * CalendarBorder - CalendarShadow
  6853.     PrintHeight     = PrintHeight - 2 * CalendarBorder - CalendarShadow
  6854.     Margin.Left     = Margin.Left + CalendarBorder
  6855.  
  6856.     BoxWidth        = PrintWidth/7
  6857.     CalRight        = Margin.Left + BoxWidth * 7
  6858.  
  6859.     TextArea        = TextArea * PrintHeight
  6860.     CalTop          = TextArea + Margin.Top + CalendarBorder
  6861.     BoxHeight       = (PrintHeight - TextArea)/5
  6862.     MoonRadius      = BoxHeight * MoonRadius
  6863.     CRadius         = CornerRadius * BoxWidth
  6864.     CurveOffset     = DateOffset * BoxWidth + CRadius * .25
  6865.     DateOffset      = DateOffset * BoxWidth
  6866.     MiniCalHeight   = TextArea * MiniCalHeight
  6867.     MiniCalWidth    = MiniCalHeight * MiniCalWidth
  6868.  
  6869.     FSize.Highlight = BoxHeight/HighlightRows * 72
  6870.     FSize.Extras    = FSize.Highlight * MagnifyExtras
  6871.     FSize.Date      = BoxHeight/HighlightRows * 72 * StretchDateH
  6872.     Width.Date      = 100 * StretchDateW / StretchDateH
  6873.     FSize.Weekday   = (TextArea - MiniCalHeight) * WeekdaySize * 72
  6874.     FSize.Header    = TextArea * HeaderSize * 72
  6875.     FSize.SubHeader = TextArea * SubHeaderSize * 72
  6876.  
  6877.     if App == 'FW' then do
  6878.       FSize.MiniCal  = MiniCalHeight/6 * 72
  6879.       do i = 0 to FontTypes
  6880.         FSize.i = min(max(trunc(FSize.i), 4), 360)
  6881.         Width.i = min(max(trunc(Width.i), 4), 255)
  6882.       end
  6883.     end
  6884.     else if App == 'PGS' then FSize.MiniCal  = MiniCalHeight/7 * 72
  6885.  
  6886.     Height.Highlight = FSize.Highlight / 4 * Height.4pt * Leading/100
  6887.     Height.Date      = FSize.Date / 4 * Height.4pt * Leading/100
  6888.     Height.Weekday   = FSize.Weekday / 4 * Height.4pt * Leading/100
  6889.     Height.Header    = FSize.Header / 4 * Height.4pt * Leading/100
  6890.     Height.MiniCal   = FSize.MiniCal / 4 * Height.4pt * Leading/100
  6891.     Height.Extras    = FSize.Extras / 4 * Height.4pt * Leading/100
  6892.     Height.SubHeader = FSize.SubHeader / 4 * Height.4pt * Leading/100
  6893.  
  6894.     if DoMiniCals == 1 then call GetMiniMax(MiniCal)
  6895.   end
  6896.   else do
  6897.     Height.4pt     = GetHeight(4pt)
  6898.     MiniCalSpacing = MiniCalSpacing / 100
  6899.  
  6900.     if ((((PrintHeight - (3 * MiniCalSpacing) - Height.4pt) / 4 ) / 7) * 72) >= 4 then DoCopyright = 1
  6901.     else DoCopyright = 0
  6902.  
  6903.     MiniCalSpacing  = PrintWidth * MiniCalSpacing
  6904.     MiniCalWidth    = (PrintWidth - 2 * MiniCalSpacing)/3
  6905.     FSize.FYMiniCal = (((PrintHeight - (3 * MiniCalSpacing) - (Height.4pt * DoCopyright)) / 4 ) / 7) * 72
  6906.     if App == 'FW' then FSize.FYMiniCal = max(trunc(FSize.FYMiniCal), 4)
  6907.     Height.FYMiniCal = FSize.FYMiniCal / 4 * Height.4pt * Leading/100
  6908.     call GetMiniMax(FYMiniCal)
  6909.   end
  6910.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  6911.  
  6912.   if App == 'FW' then do
  6913.     FIRSTOBJECT; ObjID = result
  6914.     SELECTOBJECT ObjID
  6915.     do forever
  6916.       NEXTOBJECT ObjID; ObjID = result
  6917.       if ObjID == 0 then leave
  6918.       SELECTOBJECT ObjID MULTIPLE
  6919.     end
  6920.     DELETEOBJECT
  6921.   end
  6922.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  6923.   VariablesSet = 1
  6924.   if ErrorCount > 0 then call Cleanup
  6925.  
  6926.   return
  6927. /**/
  6928.  
  6929. /***//*** TranslationStrings () ***/
  6930. TranslationStrings:
  6931. Sunday$    = 'Sunday'
  6932. Monday$    = 'Monday'
  6933. Tuesday$   = 'Tuesday'
  6934. Wednesday$ = 'Wednesday'
  6935. Thursday$  = 'Thursday'
  6936. Friday$    = 'Friday'
  6937. Saturday$  = 'Saturday'
  6938.  
  6939. January$   = 'January'
  6940. February$  = 'February'
  6941. March$     = 'March'
  6942. April$     = 'April'
  6943. May$       = 'May'
  6944. June$      = 'June'
  6945. July$      = 'July'
  6946. August$    = 'August'
  6947. September$ = 'September'
  6948. October$   = 'October'
  6949. November$  = 'November'
  6950. December$  = 'December'
  6951.  
  6952. AddEvent$       = 'Add Event'
  6953. AddIC$          = '+IC'
  6954. All$            = 'All'
  6955. BiOrWeekly$     = '(Bi)Weekly'
  6956. Biweekly$       = 'Biweekly'
  6957. Bottom$         = 'Bottom'
  6958. BoxColor$       = 'Box'
  6959. BoxDates$       = 'Box Dates'
  6960. Boxed$          = '_Boxed'
  6961. Calendar$       = 'Calendar'
  6962. Calendars$      = 'Calendars'
  6963. Cancel$         = '_Cancel'
  6964. CantFind$       = "can't be found"
  6965. Center$         = 'Center'
  6966. Clear$          = 'Clear'
  6967. Color$          = 'Color'
  6968. Colors$         = 'Colors'
  6969. Comment$        = 'Comment'
  6970. Critical$       = 'Critical error'
  6971. DailyColors$    = 'Use daily colors'
  6972. DeleteEvent$    = 'Delete Event'
  6973. Done$           = 'Done'
  6974. Easter$         = 'Easter'
  6975. End$            = 'End'
  6976. EnterEvent$     = 'You must enter an event...'
  6977. EnterEventInfo$ = 'Enter event information'
  6978. EnterNewIC$     = 'Enter new ImageClass'
  6979. EnterStartdate$ = 'You must enter a start date...'
  6980. Even$           = 'Even'
  6981. Event$          = 'Event'
  6982. Extended$       = 'Extended'
  6983. File$           = 'File'
  6984. First$          = 'First'
  6985. Fixed$          = 'Fixed'
  6986. Floating$       = 'Floating'
  6987. Font$           = 'Font'
  6988. Fonts$          = 'Fonts'
  6989. ForDetails$     = 'for details'
  6990. ForwardContent$ = 'Forward contents of output to'
  6991. ForwardLog$     = 'Forward log file to'
  6992. Fourth$         = 'Fourth'
  6993. Frequency$      = 'Frequency'
  6994. GeneratingM$    = 'Generating %s %s calendar'
  6995. GeneratingY$    = 'Generating %s calendar'
  6996. Go$             = 'Go'
  6997. Header$         = '%s %s'
  6998. HighlightEd$    = 'Highlight Editor'
  6999. Highlights$     = 'Highlights'
  7000. History$        = 'History'
  7001. Holiday$        = 'Holiday'
  7002. Images$         = 'Images'
  7003. Julian$         = 'Julian'
  7004. JulJulLeft$     = 'Jul/Jul Left'
  7005. JulLeft$        = 'Jul Left'
  7006. Last$           = 'Last'
  7007. Left$           = 'Left'
  7008. Line$           = '_Line'
  7009. Load$           = '_Load'
  7010. MatchColors$    = 'Date Color = Highlight Color'
  7011. MiniCals$       = 'MiniCals'
  7012. MiscVar$        = 'Miscellaneous Variables'
  7013. MultiMonth$     = 'Multi-Month'
  7014. MustUse$        = 'You must use the gadget to'||'0a'x||'the right for this value.'
  7015. NextDay$        = 'Next day'
  7016. Noncritical$    = 'Noncritical warning'
  7017. None$           = 'None'
  7018. NotClear$       = '<'Clear$'> can only be used for "Background." variables...'
  7019. Note$           = 'Notes'
  7020. NoteBox$        = 'Note box'
  7021. Notice$         = 'notice'
  7022. Odd$            = 'Odd'
  7023. OK$             = '_OK'
  7024. OK2$            = 'OK'
  7025. Once$           = 'Once'
  7026. Options$        = 'Options'
  7027. OptLayout$      = 'Options & Layout'
  7028. OrientMarg$     = 'Orientation & Margins'
  7029. Phases$         = 'Phases'
  7030. PleaseWait$     = 'please wait'
  7031. PrepReq$        = 'Preparing requester'
  7032. PreviousDay$    = 'Prev day'
  7033. ProcessEvents$  = 'Processing events'
  7034. Random$         = 'Random'
  7035. Reset$          = '_Reset'
  7036. Right$          = 'Right'
  7037. RiseSet$        = 'Rise/Set'
  7038. SaveAs$         = '_Save as'
  7039. Second$         = 'Second'
  7040. See$            = 'see'
  7041. SeeOutput$      = 'see the output above for details'
  7042. SeeShell$       = 'see the shell output for details'
  7043. SelectApp$      = 'Select application'
  7044. SelectFile$     = 'Select data file'
  7045. SelectFont$     = 'Select font'
  7046. SelectImage$    = 'Select image'
  7047. SelectPrefs$    = 'Select name for prefs file'
  7048. SingleMonth$    = 'Single Month'
  7049. Start$          = 'Start'
  7050. SubHeader$      = ''
  7051. Sunrise$        = 'Sunrise'
  7052. Sunset$         = 'Sunset'
  7053. Tall$           = 'Tall'
  7054. TextColor$      = 'Text'
  7055. Third$          = 'Third'
  7056. Top$            = 'Top'
  7057. TopLong$        = 'Extra week at top'
  7058. Type$           = 'Type'
  7059. Unable$         = 'if you are unable to resolve the problem.'
  7060. VarGUITitle$    = 'Set desired variables'
  7061. Variables$      = 'Variables'
  7062. Weekend$        = 'Weekend'
  7063. Weekly$         = 'Weekly'
  7064. WeekNumber$     = 'Week Number'
  7065. WeekType$       = 'Week Type'
  7066. WholeYear$      = 'Whole Year'
  7067. Wide$           = 'Wide'
  7068.  
  7069. Help$                       = 'Help message'
  7070. Help$.ClickTabHelp          = 'Different tabs display*ndifferent variables'
  7071. Help$.MiniCalsGadHelp       = 'Include mini-calendars showing*nthe previous & next months'
  7072. Help$.HighlightsGadHelp     = 'Include highlights on*nthe generated calendar'
  7073. Help$.ImagesGadHelp         = 'Include images on*nthe generated calendar'
  7074. Help$.BoxDatesGadHelp       = 'Surround day numbers*nwith boxes'
  7075. Help$.ExtendedGadHelp       = 'Include days from the previous*nand next months on the*ngenerated calendar'
  7076. Help$.TopLongGadHelp        = 'Include days from the sixth week*nat the top of the calendar'
  7077. Help$.NoteBoxGadHelp        = 'Include an area to write notes*nwhere no dates are printed'
  7078. Help$.TopMargGadHelp        = "Set calendar's top margin*nRemember to <RETURN>"
  7079. Help$.LeftMargGadHelp       = "Set calendar's left margin*nRemember to <RETURN>"
  7080. Help$.OrientationGadHelp    = "Set calendar's orientation"
  7081. Help$.RightMargGadHelp      = "Set calendar's right margin*nRemember to <RETURN>"
  7082. Help$.BottomMargGadHelp     = "Set calendar's bottom margin*nRemember to <RETURN>"
  7083. Help$.FontVarGadHelp        = 'Select the font variable to set'
  7084. Help$.FontValGadHelp        = 'Displays the choosen font value'
  7085. Help$.ChooseFontGadHelp     = 'Select the desired font'
  7086. Help$.ColorVarGadHelp       = 'Select the color variable to set'
  7087. Help$.CycleColorVarGadHelp  = 'Cycle through the color variables*nShift to reverse cycle'
  7088. Help$.ColorValGadHelp       = 'Select the desired color'
  7089. Help$.MatchColorsGadHelp    = 'Use the highlight text color*nfor the date/date box'
  7090. Help$.DailyColorsGadHelp    = 'Use the Color.(Weekday) colors*nfor the date/date box'
  7091. Help$.HighlightEditGadHelp  = 'Bring up the*nHighlight Editor'
  7092. Help$.MiscVarGadHelp        = 'Select the desired*nmiscellaneous variable'
  7093. Help$.CycleMiscVarGadHelp   = 'Cycle through the miscellaneous variables*nShift to reverse cycle'
  7094. Help$.MiscValGadHelp        = 'Enter the desired variable value'
  7095. Help$.ChooseValGadHelp      = 'Used only for selecting files/paths'
  7096. Help$.AddImageClassGadHelp  = 'Add an ImageClass variable'
  7097. Help$.Extra3Help            = "Select extra to be printed*nin calendar's top-center"
  7098. Help$.Extra4Help            = "Select extra to be printed*nin calendar's top-right"
  7099. Help$.Extra0Help            = "Select extra to be printed*nin calendar's bottom-left"
  7100. Help$.Extra1Help            = "Select extra to be printed*nin calendar's bottom-center"
  7101. Help$.Extra2Help            = "Select extra to be printed*nin calendar's bottom-right"
  7102. Help$.CalendarTypeGadHelp   = 'Select calendar type'
  7103. Help$.EndMonthGadHelp       = 'Select desired end month'
  7104. Help$.StartMonthGadHelp     = 'Select desired start month'
  7105. Help$.MonthGadHelp          = 'Select desired month'
  7106. Help$.YearGadHelp           = 'Select or enter desired year'
  7107. Help$.GoGadHelp             = 'Begin generation of calendar'
  7108. Help$.ResetGadHelp          = 'Reset all variables to defaults'
  7109. Help$.LoadGadHelp           = 'Load a new preference file'
  7110. Help$.SaveAsGadHelp         = 'Save current settings to*na new preference file'
  7111. Help$.CancelGadHelp         = 'Cancel FWCalendar'
  7112. Help$.EH_EventGadHelp       = 'Enter the Highlight as it*nwill show up on calendar'
  7113. Help$.EH_ChooseEventGadHelp = 'Select Image file to be printed on calendar'
  7114. Help$.EH_ListEventGadHelp   = 'List all Highlights*nfor current month'
  7115. Help$.EH_CycleEventGadHelp  = 'Cycle through all Highlights*nfor current month'
  7116. Help$.EH_CommentGadHelp     = 'Enter optional comment'
  7117. Help$.EH_MonthGadHelp       = 'Select month to work with'
  7118. Help$.ExtraDHelp            = 'Select the date on*nwhich the Highlight falls'
  7119. Help$.LD                    = 'Indicates the Highlight always falls*non the last day of the month'
  7120. Help$.EH_ColorGadHelp       = 'Select color to be*nused for the Highlight'
  7121. Help$.EH_HLTypeGadHelp      = 'Select the Highlight type'
  7122. Help$.EH_WeekNumberGadHelp  = 'Select which week a floating*nHighlight occurs in'
  7123. Help$.EH_WeekTypeGadHelp    = 'Select frequency of weekly Highlights'
  7124. Help$.EH_WeekendGadHelp     = 'Determine whether or not the*nHighlight can fall on a weekend'
  7125. Help$.EH_HolidayGadHelp     = 'Treat the Highlight as a holiday'
  7126. Help$.EH_EasterGadHelp      = 'The number of days before or*nafter Easter for the Highlight'
  7127. Help$.EH_AddEventGadHelp    = 'Add a new Highlight'
  7128. Help$.EH_DeleteEventGadHelp = 'Delete the currently*ndisplayed Highlight'
  7129. Help$.EH_DoneGadHelp        = 'Save all changes to Highlights'
  7130. Help$.GE_EventTypeGadHelp   = 'Select to enter Event or*nuse an Event file'
  7131. Help$.GE_EventGadHelp       = 'Enter Event or display Event file'
  7132. Help$.GE_FontNameGadHelp    = 'Display font to be used'
  7133. Help$.GE_FontSizeGadHelp    = 'Enter font size to use'
  7134. Help$.GE_ChooseFontGadHelp  = 'Select font to be used'
  7135. Help$.GE_ResetGadHelp       = 'Reset font and font size'
  7136. Help$.GadIDHelp             = 'Enter Event start and end dates'
  7137. Help$.GE_StartGadHelp       = 'Display Event start date'
  7138. Help$.GE_EndGadHelp         = 'Display Event end date'
  7139. Help$.GE_TextColorGadHelp   = 'Select color to be*nused for Event text'
  7140. Help$.GE_LineGadHelp        = 'Select row on which*nEvent will be printed'
  7141. Help$.GE_BoxedGadHelp       = 'Surround Event with a box'
  7142. Help$.GE_BoxColorGadHelp    = 'Select color for box*nsurrounding Event'
  7143. Help$.GE_FrequencyGadHelp   = 'Select frequency of Event'
  7144. Help$.GE_OKGadHelp          = 'Use entered data to add*nEvent to calendar'
  7145. Help$.GE_CancelGadHelp      = 'Cancel FWCAddEvent'
  7146.  
  7147. return 0
  7148. /**/
  7149.  
  7150. /***//*** VarList () ***/
  7151. VarList:
  7152.   AddEventRows             = 9
  7153.   AdjustDST                = 1
  7154.   AltColor.Date            = Black$
  7155.   AltColor.Extended        = Black$
  7156.   AltColor.Highlight       = Black$
  7157.   AltColor.HighlightH      = Black$
  7158.   AltColor.History         = Black$
  7159.   AltColor.Julian          = Black$
  7160.   AltColor.Random          = Black$
  7161.   AltColor.Sunrise         = Black$
  7162.   AltColor.Sunset          = Black$
  7163.   AltColor.WeekNumber      = Black$
  7164.   Background.AddEvent      = White$
  7165.   Background.CalShadow     = Black$
  7166.   Background.Highlight     = '<'Clear$'>'
  7167.   Background.HighlightH    = '<'Clear$'>'
  7168.   Background.MiniCal       = White$
  7169.   Background.MiniCalShadow = Black$
  7170.   Background.NoteBox       = '<'Clear$'>'
  7171.   Background.Standard      = '<'Clear$'>'
  7172.   Background.Weekend       = '<'Clear$'>'
  7173.   BelzierFactor            = .55
  7174.   Bold.MiniCal             = DefaultBold
  7175.   Bold.FYMiniCal           = DefaultBold
  7176.   CalendarBorder           = 0
  7177.   CalendarShadow           = 0
  7178.   CenterHistory            = 1
  7179.   CenterMiniDates          = 1
  7180.   CenterRandom             = 1
  7181.   Color.Sunday             = Black$
  7182.   Color.Monday             = Black$
  7183.   Color.Tuesday            = Black$
  7184.   Color.Wednesday          = Black$
  7185.   Color.Thursday           = Black$
  7186.   Color.Friday             = Black$
  7187.   Color.Saturday           = Black$
  7188.   Color.AddEvent           = Black$
  7189.   Color.Date               = Black$
  7190.   Color.Extended           = Black$
  7191.   Color.Header             = Black$
  7192.   Color.Highlight          = Black$
  7193.   Color.HighlightH         = Black$
  7194.   Color.History            = Black$
  7195.   Color.Julian             = Black$
  7196.   Color.MiniCal            = Black$
  7197.   Color.Moon               = Black$
  7198.   Color.NoteBox            = Black$
  7199.   Color.Random             = Black$
  7200.   Color.SubHeader          = Black$
  7201.   Color.Sunrise            = Black$
  7202.   Color.Sunset             = Black$
  7203.   Color.Weekday            = Black$
  7204.   Color.WeekNumber         = Black$
  7205.   CornerRadius             = 0
  7206.   DateOffset               = 2
  7207.   DoDailyColors            = 0
  7208.   DoDateBox                = 0
  7209.   DoExtended               = 1
  7210.   DoHide                   = 0
  7211.   DoHighlights             = 0
  7212.   DoHistory                = ''
  7213.   DoImages                 = 0
  7214.   DoJulian                 = ''
  7215.   DoJulianLeft             = ''
  7216.   DoMatchColors            = 0
  7217.   DoMiniCals               = 1
  7218.   DoNoteBox                = 0
  7219.   DoPhases                 = ''
  7220.   DoRandom                 = ''
  7221.   DoSunRise                = ''
  7222.   DoSunSet                 = ''
  7223.   DoTopExtraWk             = 0
  7224.   DoWeekNumber             = ''
  7225.   FinalView                = 75
  7226.   Font.Date                = DefaultFont
  7227.   Font.Extras              = DefaultFont
  7228.   Font.Header              = DefaultFont
  7229.   Font.Highlight           = DefaultFont
  7230.   Font.MiniCal             = DefaultFont
  7231.   Font.FYMiniCal           = DefaultFont
  7232.   Font.Weekday             = DefaultFont
  7233.   Font.SubHeader           = DefaultFont
  7234.   ForceBGUI                = 0
  7235.   GenMVars                 = 'Month.Month EnteredYear'
  7236.   GenYVars                 = 'EnteredYear'
  7237.   GfxApp                   = 'Visage'
  7238.   GfxAppPath               = ''
  7239.   HeaderLoc                = 9
  7240.   HeaderSize               = 50
  7241.   Header$                  = '%s %s'
  7242.   HeaderVars               = 'Month.Month Year'
  7243.   HelpTime                 = 4
  7244.   HighlightRows            = 9
  7245.   HostScreen               = ''
  7246.   LaunchM                  = ''
  7247.   LaunchY                  = ''
  7248.   Leading                  = 100
  7249.   Line.AddEvent            = Black$
  7250.   Line.CalBorder           = Black$
  7251.   Line.Extended            = Black$
  7252.   Line.Grid                = Black$
  7253.   Line.MiniCal             = Black$
  7254.   Line.NoteBox             = Black$
  7255.   MagnifyExtras            = 100
  7256.   Margin.Bottom            = 0
  7257.   Margin.Left              = 0
  7258.   Margin.Right             = 0
  7259.   Margin.Top               = 0
  7260.   MinHistoryWidth          = 70
  7261.   MinRandomWidth           = 70
  7262.   MinWidth                 = 80
  7263.   MaxImgHeight             = 75
  7264.   MaxImgWidth              = 75
  7265.   MiniCalHeight            = 60
  7266.   MiniCalSpacing           = 0.5
  7267.   MiniCalWidth             = 200
  7268.   MoonRadius               = 10
  7269.   Orientation              = 'Wide'
  7270.   PrefsName                = 'Default'
  7271.   ShadowType               = 'P'
  7272.   ShiftLMini               = 0
  7273.   ShiftRMini               = 0
  7274.   StartWeek                = 0
  7275.   StretchDateH             = 100
  7276.   StretchDateW             = 100
  7277.   SubHeaderLoc             = 0
  7278.   SubHeaderSize            = 0
  7279.   SubHeader$               = ''
  7280.   SubHeaderVars            = ''
  7281.   SunCalcPath              = ''
  7282.   Text.Julian              = ''
  7283.   Text.Sunrise             = ''
  7284.   Text.Sunset              = ''
  7285.   Text.WeekNumber          = ''
  7286.   TextAdj                  = 77
  7287.   TTextArea                = 15
  7288.   WeekdaySize              = 50
  7289.   WTextArea                = 20
  7290. return
  7291. /**/
  7292.  
  7293.